¿Cuáles son las mejores prácticas para almacenar conjuntos anidados (como árboles de comentarios) en MongoDB?MongoDB conjuntos anidados
Quiero decir, cada comentario puede tener un comentario principal y comentarios de niños (respuestas).
almacenarlos como esto:
{
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" },
]
}
no es fresco, porque no podemos, por ejemplo, pedir "todos los post que se ha comentado por Peter" sin map/reduce.