I have a document like this:
solution:{
"name":"solution name",
"desc":"description",
"case":[
{
"A":13,
"B":"aaaa"
},
{
"A":14,
"B":"aaaa"
},
{
"A":13,
"B":"bbbb"
}
]
}
The case is an array field in solution table, and it contains two fields, field A and filed B.
Now I can query the solution record, and the return result will include all case elements. Now I wish the query result only includes case elements which filed B is "aaaa", how to write the query in java or MongoDB?
My expected query result should be like this:
solution:{
"name":"solution name",
"desc":"description",
"case":[
{
"A":13,
"B":"aaaa"
},
{
"A":14,
"B":"aaaa"
},
]
}