Reputation: 3400
I have a schema that has an array of objects.
{
"data": {
"array": [
{
"field 1": "blahblah",
"field 2": "blahblah"
},
...
]
}
}
so i would like to only get records in which none of the "array" element have "field 1" as an empty string. What is the most efficient way of doing this?
Upvotes: 2
Views: 2364
Reputation: 311865
When used with an array field, the $ne
value must not match any array element for the document to be included, so you can simplify your query to:
MyModel.find({'data.array.field 1': {$ne: ''}});
Upvotes: 4