[Mongoose] How to Specify Two or More Different OR Conditions

Tadashi Shigeoka ·  Fri, August 2, 2013

Here’s how to specify two or more different OR conditions in Node.js + Mongoose.

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.

Reference Information

That’s all from the Gemba.