Reputation: 1237
I have an document with an embedded array of documents. i.e. 'key' => array(...)
Is it possible to create a query so that for some value in the embedded array, all of them are $lt some value?
So like this:
{
'key.value' : { $lt : 5.0 }
}
Problem there is as soon as one is $lt then it matches which i dont want, I want all should be less than 5.
Upvotes: 2
Views: 1758
Reputation: 606
How about using the $not operator? Specifically, match all the values you don't want, then get the opposite. So something like:
{
'key.value' : { $not : { $gte : 5.0 }}
}
Would get all the documents which don't have values in the array greater than or equal to five, which is what I think you want, right?
Upvotes: 9