mongodb and 和 or语句写法

来源:互联网 发布:js input 属性的值 编辑:程序博客网 时间:2024/05/29 18:29

 形如 a>1 and b>2 or c>3 and d>4 的逻辑查询,如果使用mongodb查询,应该写为:

db.example.find({    '$or':[       {'$and':[{'example.a':{'$gt':1}},{'example.b':{'$gt':2}}]},       {'$and':[{'example.c':{'$gt':3}},{'example.d':{'$gt':4}}]}    ]})
0 0
原创粉丝点击