$and $not null 正则表达式

查询MasterID大于1且MasterType等于TestType的文档:

db.SysCore.find({$and:[{"MasterID":{$gt:1}},{"MasterType":"TestType"}]}).pretty()

结果如下:

查询MasterID不等于2且MasterName以"测试"开头的文档:

db.SysCore.find({$and:[{"MasterID":{ $not:/2/}},{"MasterName":/测试+/}]})

Syntaxfield: $not: <operator-expression> }

db.inventory.find( { price: { $not: { $gt: 1.99 } } } )
db.inventory.find( { item: { $not: /^p.*/ } } )

结果如下:

查询MasterSort为null的文档:

既要查询为null,同时也要保证存在。

db.SysCore.find({"MasterSort":{$in:[null],$exists:true}}).pretty()

结果如下:

くろさきいちご
原文地址:https://www.cnblogs.com/Andy-Li/p/5888222.html