标签:
MongoDB OR 条件语句使用了关键字 $or,语法格式如下:
>db.col.find(
{
$or: [
{key1: value1}, {key2:value2}
]
}
).pretty()
> db.user.find({$or:[{"name":"admin","grade":"99"}]}).pretty()
> db.user.find({$or:[{"name":"admin","grade":"99"}]}).pretty()
> db.user.find({$or:[{"name":"admin"},{"grade":"99"}]}).pretty()
{
"_id" : ObjectId("56946fba3a18f4867aecbcd1"),
"name" : "admin",
"password" : "123456",
"title" : "admin",
"grade" : 50
}
> db.user.find({$or:[{{"grade":"99"},{"name":"admin"}]}).pretty()
...
没太明白$or的究竟
标签:
原文地址:http://www.cnblogs.com/mxh1099/p/5123939.html