mongodb语句

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"}} //小于某个时间

    ]

})

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容