Quali sono le migliori pratiche per archiviare set annidati (come alberi di commenti) in MongoDB?Set nidificati MongoDB
Voglio dire, ogni commento può avere un commento principale e commenti-bambini (risposte).
memorizzandoli in questo modo:
{
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" },
]
}
non è freddo, perché non possiamo, ad esempio, chiedere "tutti Inserisci vengono commentati da Peter" senza mappa/ridurre.