[Mongoose] 異なるOR条件を2つ以上指定したい場合の書き方

Node.js + Mongoose にて異なるOR条件を2つ以上指定したい場合の書き方をご紹介します。

mongoose | マングース

Test.find({
  $and: [
    { $or: [{a: 1}, {b: 1}] },
    { $or: [{c: 1}, {d: 1}] }
  ]
}, function (err, results) {
  // do something
}

$and を使って、明示的に $or を複数組み合わせて指定するだけでOKです。

参考情報