Last active
October 7, 2016 18:42
-
-
Save jde/e64306c85b4345701cba33b2e786241a to your computer and use it in GitHub Desktop.
Proposed item relationship format for views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a proposed format for representing relationsips in items when | |
// they are rendered into views. This optimizes both for transport and | |
// lookup efficiency on the front end. | |
// compacting rels into arrays of keys in hashes with the name of the rel as the key will: | |
// 1) allow lookups on the fe without needing to iterate | |
// 2) compact the data into the tightest possible (with json at least) format for transport | |
{ | |
_id: "23423423", | |
type: "user", | |
data: { | |
name: "fred" | |
}, | |
rels: { | |
"wrote": ['23423423', '23423423', '23423423', '23423423'], | |
"follows": ['2342ewr23', '2342ewr23'] | |
} | |
}, | |
{ | |
t: "comment", | |
d: { | |
body: "The quick brown fox WASN'T FAST ENOUGH" | |
}, | |
rels: { | |
"author": ['23423423'], | |
"context": ['32l4j2l3k4j'] | |
} | |
} | |
... | |
Yes. so a comment might have:
rels : {
'replies': ['abcd', 'qaaa', 'aclu']
}
or
rels: {
'replyTo': ['abcd']
}
I'd love to check in about how to best provide the info necessary for these relationships. For example: it's easy for me to post new comments with a 'replyTo' field, I want to make sure I'm giving you all what you need to populate the 'replies' relationship in the parent comment appropriately.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! Are you thinking on model this same way the comments on comments relationships?