mongo find-in,or,and,not

 $in:

{ field: { $in: [<value1>, <value2>, ... <valueN> ] } }

db.inventory.find( { qty: { $in: [ 5, 15 ] } } )

$or:

{ $or: [ { <expression1> }, { <expression2> }, ... , { <expressionN> } ] }
db.inventory.find( { $or: [ { qty: { $lt: 20 } }, { sale: true } ] } )

$and:

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

  db.inventory.find({ $and: [ { price: 1.99 }, { qty: { $lt: 20 } }, { sale: true } ] } )

$not:

{ field: { $not: { <operator-expression> } } }

db.inventory.find( { price: { $not: { $gt: 1.99 } } } )
原文地址:https://www.cnblogs.com/xiaoxiaof/p/3678345.html