條件:查詢status:2,has_pay:true,amount:不等於0,type:A或者空(type類型有4個,分別是A、B、C、以及部分字段為空)的訂單
反向查詢:
db.order.find({ "status": NumberInt(2), "has_pay": true, "amount": { $ne: NumberInt(0) },$and: [ { "type":{ $ne: "C" } }, { "type": { $ne: "B"} } ]})
或者
db.order.find({ "status": NumberInt(2), "has_pay": true, "amount": { $ne: NumberInt(0) }, $nor: [ { "type": "C" }, { "type": "B" } ] })
正向查詢:
db.order.find({ "status": NumberInt(2), "has_pay": true, "amount": { $ne: NumberInt(0) }, $or: [ { "type": "A" }, { "type": null } ] })