I have serious trouble finding anything useful in Mongo documentation about dealing with embedded documents. Let's say I have a following schema:
{
_id: ObjectId,
...
data: [
{
_childId: ObjectId // let's use custom name so we can distinguish them
...
}
]
}
What's the most efficient way to remove everything inside
datafor particular_id?What's the most efficient way to remove embedded document with particular
_childIdinside given_id? What's the performance here, can_childIdbe indexed in order to achieve logarithmic (or similar) complexity instead of linear lookup? If so, how?What's the most efficient way to insert a lot of (let's say a 1000) documents into
datafor given_id? And like above, can we get O(n log n) or similar complexity with proper indexing?What's the most efficient way to get the count of documents inside
datafor given_id?