I have a collection with embedded array of objects. I need a query to select only those documents where each of embedded objects
prop equals to some value:
{
{
_id: 1,
objects: [{prop_1: ..., foo: true}, {prop_1: ..., foo: false}, {prop_1: ...}]
},
{
_id: 2,
objects: [{prop_1: ..., foo: false}, {prop_1: ..., foo: false}, {prop_1: ...}]
},
{
_id: 3,
objects: [
{prop_1: ..., foo: true}, {prop_1: ..., foo: true}, {prop_1: ..., foo: true}
]
}
}
I need a query to get all the documents where each element of objects
has foo === true
. If one of objects.foo
is not exists or not equals true
do not return this document in result. In this case only record with _id : 3
meets this condition.