I'm still confused which structure is better structure using MongoDB.
Place child in parent:
{
"_id": "528ba7691738025d11aab772",
"post": "Hello 1",
"childs": [
{
"_id": "528ba7691738025d11aab555",
"post": "Hello 2",
"childs": []
},
{
"_id": "528ba7691738025d117631783",
"post": "Hello 22",
"childs": [
{
"_id": "528ba7612D38025d11aab772",
"post": "Hello 3",
"childs": []
}
]
}
]
}
Place child equal with the parent like relational database do:
[
{
"_id": "528ba7691738025d11aab772",
"post": "Hello 1",
"parent_id": null
},
{
"_id": "528ba7691738025d11aab555",
"post": "Hello 2",
"parent_id": "528ba7691738025d11aab772"
},
{
"_id": "528ba7691738025d117631783",
"post": "Hello 22",
"parent_id": "528ba7691738025d11aab772"
},
{
"_id": "528ba7612D38025d11aab772",
"post": "Hello 3",
"parent_id": "528ba7691738025d117631783"
}
]