I have a JSON in MongoDB with collection name StudentData as:
"data" : {
"students":{
"A":{
"roll":"11",
"otherDetails":{
"name":"AAA"
}
},
"B":{
"roll":"12",
"otherDetails":{
"name":"BBB"
}
},
"C":{
"roll":"13",
"otherDetails":{
"name":"CCC"
}
},
"D":{
"roll":"14",
"otherDetails":{
"name":"DDD"
}
}
}
}
How can I fetch all students A, I tried the following db.StudentData.find({"data.students":"A"}) but it is returning nothing .
I am trying to get this:
{
"roll":"11",
"otherDetails":{
"name":"AAA"
}
}
What could be it's Java Equivalent and Mongo equivalent queries?