Reputation: 7479
my query:
{ 'objects.item.opts1.opts2': { '$elemMatch': [ { name: 'false' } ] } }
returns: any item that has anything in the array opts2, even if I change 'name' to some field that is not present the result will always be the same
mongoose schema:
var MySchema = new Schema({
objects: {
item: {
opts1: [{
opts2: [{
name: { type: String },
}]
}],
},
});
Upvotes: 0
Views: 83
Reputation: 944
Use following wihout array in $elemMatch....
{ 'objects.item.opts1.opts2': { '$elemMatch': { name: 'false' } } }
Upvotes: 4