Hi and thanks for helping. I need to insert data to a MongoDB collection and I confused, which approached is better, nested or flat way.
For example: one nested document
{
a: [ {
aName: 'name',
b: [ {
bName: 'name'
} ]
}
or many flat and small documents
{
a: 'name',
b: 'name'
}
Comments:
there isn't update query, just insert (and get)
the nested object is not huge (not overflow the limit)
my thinks for the nested way:
it's more verbose, its help to the next person that looking on the collection to understand the hierarchy
the get is simpler, and the code for get is more readable
my thinks for the flat way:
- maybe in the future should do more aggregeation on the collection, it will be easier.