robomongo操作MongoDB数据库常用命令(更新中)

1.删除包含指定字段的文档:

db.getCollection('集合名').update({'字段名':{$exists:true}}, {$unset:{'字段名':''}}, {multi:true})

2.查找某个字段不存在的文档:

db.getCollection('集合名').find({'字段名':{$exists:false}})

3.多字段查询:

db.getCollection('集合名').find({'字段1':{$exists:false},'字段2':{$exists:true}}).count()

4.按照指定排序输出显示:
db.getCollection('集合名').find().sort({"字段名":-1}) 

猜你喜欢

转载自blog.csdn.net/qq_27378621/article/details/80006734