Reputation: 589
I have a collection in mongodb. Here is the link https://mongoplayground.net/p/aDMwOc5Wal4. I need all the Dogs, Oranges and Red colored vegetables.
I am trying a query but not getting the approach.
Upvotes: 2
Views: 77
Reputation: 13393
you can try this.
db.collection.find({
$or: [
{
"type": {
"$in": [
"Dog",
"Orange"
]
}
},
{
$and: [
{
"color": {
"$in": [
"red"
]
},
"cat": {
"$in": [
"Vegetable"
]
}
}
]
}
]
})
Upvotes: 2