$or操作符

$or操作符

  The $or operator performs a logical OR operation on an array of two or more <expressions> and selects the documents that satisfy at least one of the <expressions>. The $or has the following syntax:

{ $or: [ { <expression1> }, { <expression2> }, ... , { <expressionN> } ] }

  Consider the following example:

db.inventory.find( { $or: [ { quantity: { $lt: 20 } }, { price: 10 } ] } )

  This query will select all documents in the inventory collection where either the quantity field value is less than 20 or the price field value equals 10.

  

原文地址:https://www.cnblogs.com/tekkaman/p/4901222.html