在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" },
]
}
是不冷靜,因爲我們不能,例如,索要無地圖「它是由彼得·評論所有文章」 /減少。