What're the best practices to store nested sets (like trees of comments) in MongoDB?
I mean, every comment can have a parent comment and children-comments (answers).
Storing them like this:
{
title: "Hello",
body: "Please comment me!",
comments: [
{
author: "Peter",
text: "Hi there",
answers: [
{
author: "Peter",
text: "Hi there",
answers: [
{ author: "Ivan", text: "Hi there" },
{ author: "Nicholas", text: "Hi there" }
]
},
{ author: "Ivan", text: "Hi there" },
{ author: "Nicholas", text: "Hi there" },
]
},
{ author: "Ivan", text: "Hi there" },
{ author: "Nicholas", text: "Hi there" },
]
}
is not cool, because we can't, for example, ask for "all post which are commented by Peter" without map/reduce (hm, can we?)