1、 in、not in 查询
db.getCollection('OperationLog').find({
"SystemCode" : "10",
//"OperationCode" : { $in : ["130", "131", "132", "135", "133", "9", "10", "11"] },
"OperationCode" : { $nin : ["15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "130", "131", "132", "135", "133", "134", "136", "137", "138", "139", "140", "141", "142", "143", "9", "10", "11", "12", "13", "14"] }
})
2、 != 查询
db.getCollection('OperationLog').find({
"SystemCode" : "20",
"InvokeSystemCode" : {$ne:"20"}
})
3、 查询内嵌文档
db.getCollection('OperationLog').find({
"SystemCode" : "20",
"DetailInfo.PersonID" : "33AECBB8-1897-462F-B746-A50A92CEDD31"
})
4、 like查询
db.getCollection('OperationLog').find({
"SystemCode" : "20",
"PageName" : /登录/,
//"PageName":/^登录/, //匹配位置模糊搜索
//"PageName": /\\(/, //匹配带括号的值
})
4、查日期
db.getCollection('operationLog').find({
"CreateTime":{$gte:"2018-03-07"}
})
5、查询时间范围
db.OperationLog.find({
"$and":[
{"CreateTime":{"$gt":"2018-03-09 0:0:0"}}, //大于某个时间
{"CreateTime":{"$lt":"2018-03-27 59:59:59"}} //小于某个时间
]
})