ネストされたセット (コメントのツリーなど) を 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" },
]
}
たとえば、map/reduce なしでは「Peter がコメントしたすべての投稿」を求めることはできないため、クールではありません。