I have this collection in MongoDB in this Structure.Now I need to query the on this data to get the relatedPeople with weight 60. I searched on this but found noting specific most query give data using $ symbol but it gives you rootnode but not the info that which nested node is maching.
{
"_id": "7686348264868327",
"Name": "myName",
"phoneNo": "12434576896",
"ExtraDetails": {
"TotalPeople": 10,
"activePeople": 8,
"lostPeople": 2,
"relatedPeople": [{
"Name": "reev",
"Relation": "Father",
"Weight": 60
},
{
"Name": "magen2",
"Relation": "Mother",
"Weight": 60
},
{
"Name": "neo",
"Relation": "Gardian",
"Weight": 70
}
]
}
}
{
"_id": "76866898698798",
"Name": "myName2",
"phoneNo": "867867868",
"ExtraDetails": {
"TotalPeople": 8,
"activePeople": 6,
"lostPeople": 2,
"relatedPeople": [{
"Name": "amazing",
"Relation": "Father",
"Weight": 60
},
{
"Name": "caring",
"Relation": "Mother",
"Weight": 90
},
{
"Name": "neo",
"Relation": "Gardian",
"Weight": 75
}
]
}
}
The Output Should be Something Like This
"relatedPeople":[
{
"Name": "reev",
"Relation": "Father",
"Weight": 60
},
{
"Name": "magen2",
"Relation": "Mother",
"Weight": 60
},
{
"Name": "amazing",
"Relation": "Father",
"Weight": 60
}
]
Or
[{
"Name": "reev",
"Relation": "Father",
"Weight": 60
},
{
"Name": "magen2",
"Relation": "Mother",
"Weight": 60
},
{
"Name": "amazing",
"Relation": "Father",
"Weight": 60
}]