mongodb 常用不好写命令整理
2015-10-27 本文已影响38人
小武子
- select * from db.co order by id DESC limit 5
db.co.find().limit(5).sort({"_id":-1})
- find some items not exists in collection:
db.co.find({ "item":
{ "$exists" : False }
})
- skip
db.co.find().skip(5).limit(5)
- delete from db.co where age < 30
db.co.remove({ 'age' : {$lt : 30}})
- select age from db.co
db.co.find({},{"age" : 1})
- select others(not age) from db.co
db.co.find({},{"age" : 0})