MongoDB nested sets -
Is MongoDB the best practices for storing nested sets (comments trees)?
I mean, every comment can have a parental comment and children-comments (answers).
Store them in this way:
{title: "hello", body: "Please comment.", Comment: [[Author: "Peter" Text: "Hi there", Answer: [[Author: "Peter", lesson: "Hi there", Answer: [[Author: "Ivan", lesson: "Hi there"}, {author: "Nicholas", lesson : "Hi there"}}, {author: "Ivan", text: "Hi there"}, {author: "Nicholas", text: hello "},]}, {author:" Ivan ", lesson: Hi there "}, {author:" nicholas ", text:" hi there "},]}
is not good because we can not, for example , "All posts, which are commented by Peter" without the map / less.
me It seems that there is no correct solution - depending on which operations are more important for your app. I believe that for example, the nested silicon ali insider store, with MongodiBee, allows you to query Make it difficult.
An option is available for all the commentators in an array. In Prachi, there is a store at the top level, think of it as denormalized data, then one can easily find all the positions that contain a definite commenter. Then to drill down, you use the map / less or db.value () inside nested post information.
Another note - If you are working with a document, then db.eval () is probably less weight than the map. $ Where there is also an option but may be slow, so I like the list of additional commenters mentioned above - it's not easy for the index (see 'Multikie' in Docs).
Also see:
Comments
Post a Comment