{
"_id" : 123,
"someKey" : "someValue",
"someArray" : [
{
"name" : "name1",
"someNestedArray" : [
{
"name" : "value_1",
"fame" : [
{
"goal" : "goal_1"
}
]
},
{
"name" : "value_2",
"fame" : [
{
"goal" : "goal_2"
}
]
}
]
}
]
}
I does the query like:
db.getCollection('city').find({"someArray.0.someNestedArray.1.fame.0.goal":"goal_2"},{"someArray.0.someNestedArray.":1})
But get the output as:
{
"_id" : 123,
"someArray" : [
{}
]
}
What is the query for getting the output as:
{
"fame" : [
{
"goal" : "goal_2"
}
]
}
Thanks in advance. Also tell how to find a value in nested array when one don't know the indexes. The query I have done specifies the array element position (someArray.0.someNestedArray.1.fame.0.goal)