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

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

结果如下:

$and  $not  null  正则表达式

 

查询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.*/ } } )

结果如下:

$and  $not  null  正则表达式

 

查询MasterSort为null的文档:

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

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

结果如下:

$and  $not  null  正则表达式

相关文章:

  • 2022-12-23
  • 2021-11-03
  • 2021-11-22
  • 2021-10-29
  • 2021-07-01
  • 2021-08-01
  • 2021-06-04
  • 2022-12-23
猜你喜欢
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案