I'm wondering if anyone else have run into this problem in MongoDB.
I'm trying to search an array inside another array with $elemMatch
and then see if a nested value inside of this document, is in an array of values I provide.
Below there is a simple example:
db.p.insert({v: [{o: [{s: {e: ["M"] }} ]} ]});
db.p.findOne({"v.o": {"$all": [{"$elemMatch": {"s.e": {"$in": ["M"]}}}]}});
null
Note, the reason for the $all
statement is that I want to be able to match several different fields, where each field doesn't necessarily exist on the documents in the array.