I have a json document which has a structure as is displayed below:
{
"125": {
"name": "sample name one",
"age" : 22,
},
"126": {
"name": "sample name two",
"age" : 27,
},
"127": {
"name": "sample name three",
"age" : 21,
}
}
I want to return the object represented by 125, i.e. the following object :
{
"name": "sample name one",
"age" : 22,
}
I have tried the following query from the console, but I cannot get the result I need:
db.persons.find({"125": {$exists: true}})
.
I would like to know how to query the database to return the data that I need. Thank you for any help.