在MongoDB中存储嵌套集(如注释树)的最佳实践是什么?MongoDB嵌套集
我的意思是,每个评论可以有一个家长评论和儿童评论(答案)。
存储他们这样的:
{
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" },
]
}
是不冷静,因为我们不能,例如,索要无地图“它是由彼得·评论所有文章” /减少。