您的位置:首页 > 数据库 > Mongodb

mongodb and 和 or语句写法

2015-08-25 08:53 676 查看
形如
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}}]}
]
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: