I'm stuck with a MongoDB collection that looks like below. I want to query for documents that match flag: true
and match if any object below bar
matches value: "v_b"
.
As I fail to understand how to query past bar's array and had no luck using aggregation, I'd be grateful for an example – thanks a lot.
{
"flag": true,
"foo" : {
"name" : "dont care",
"bar" : [
{
"a" : {
"name": "n_a",
"value" : "v_a"
},
"b" : {
"name": "n_b",
"value" : "v_b"
},
"c" : {
"name": "n_c",
"value" : "v_c"
}
}
]
}
},
{
"flag": false,
"foo" : { ... }
}