I am having trouble trying to find the owner of a sub-document nested at the nth level.
Here's the proposed document structure.
{
"_id": "foo_l0",
"subdocs" : [
{
"_id" : "foo_0_l1"
},
{
"_id" : "foo_1_l1",
"subdocs": [
{
"_id": "foo_0_l2",
"subdocs": [
{
"_id": "foo_0_ln",
"subdocs" : []
}
]
},
{
"_id": "foo_1_l2",
"subdocs": [
{
"_id": "foo_0_ln",
"subdocs": []
}
]
}
]
}
]
}
I want to be able to find foo_l0, using foo_0_ln which is nested at the nth level. (n is unkown)
In other words, is it possible to query MongoDB using the id of one of the sub-documents no matter how deep they're nested inside the owner document?