Mongo常用命令
###根据日期查找
1 | db.getCollection('webExceptionRecord').find({createdDate: {"$gte":ISODate("2016-03-31T12:48:25.040+08:00")}}) |
###根据日期倒序排序
1 | db.getCollection('webExceptionRecord').find({}).sort({createdDate:-1}) |
###查询“不等于”
1 | db.getCollection('webExceptionRecord').find({version: {$not:/v5\.0\.5/}}) |
$not
后边必须跟正则表达式或文档(regex or document)
1 | db.getCollection('webExceptionRecord').find({version:{$nin:['v5.0.5']}}) |
$nin
: not in
1 | db.getCollection('appStatisticsActiveUser').find({count:{$not: {$lt:100}}}) |
###查询“包含”
1 | db.getCollection('webExceptionRecord').find({version: {$regex:/.*5\.0\.5.*/}}) |
###查询“不包含”
1 | db.getCollection('webExceptionRecord').find({version: {$not:/.*v5\.0\.5.*/}}) |
转载请注明出处:Mongo常用命令
原文地址:https://www.xiaotanzhu.com/%E5%88%86%E5%B8%83%E5%BC%8F%E7%B3%BB%E7%BB%9F/2016-07-19-mongo-queries.html