[Mongoose] How to Specify Two or More Different OR Conditions
Here’s how to specify two or more different OR conditions in Node.js + Mongoose.
Test.find({
$and: [
{ $or: [{a: 1}, {b: 1}] },
{ $or: [{c: 1}, {d: 1}] }
]
}, function (err, results) {
// do something
}
Just use $and to explicitly combine multiple $or conditions.
That’s all from the Gemba.