Answer the question
In order to leave comments, you need to log in
MongoDB how to check all occurrences of an array?
I have a db with users like this:
{
"_id": 1,
"name": "Carlo",
"cars": [{
"type": "sport",
"score": 10
}, {
"type": "hatchback",
"score": 5
}, {
"type": "family",
"score": 4
}, {
"type": "family",
"score": 3
}]
}
db.bsa.find({
$and: [{
'cars.score': {
$gt: 5
}
}, {
'cars.score': {
$lt: 8
}
}]
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question