Reputation: 1991
I have a collection with many documents;
I would like to return all documents where individuals are (older than 30 AND less than 37 years old), OR live in Italy.
My attempt
db.getCollection('persons')
.find(
$or:[
{$and: [
{age:{$gte:30}},
{age:{$lt:37}}
],
{"company.location.country": "Italy"}
]
)
Which yields an error
Upvotes: 0
Views: 47
Reputation: 2721
It can be simplified to
{
$or: [
{ age: { $lt: 37, $gte: 30 } },
{ "company.localtion.country": "Italy" }
]
}
Upvotes: 1