I have this kind of elements:
{ "_id" : 1,
"docs" : [
{ "key": "blah", "count": 2},
{ "key": "wow", "count": 10}
]
},
{ "_id" : 2,
"docs" : [
{ "key": "blah", "count": 11}
}
I want to retrive elements which has NOT the docs.key == "wow"
defined. In this case the element "_id": 2
.
Whith this query I get the opposite:
db.getCollection('myCollection').find(
{
"docs.key": "wow"
}
);
I have tried combinations of $exists
and aggregate
but I don't find the proper solution.