//大于: field > value
db.collection.find({field:{$gt:value}});
//小于: field < value
db.collection.find({field:{$lt:value}});
//大于等于: field >= value
db.collection.find({field:{$gte:value}});
//小于等于: field <= value
db.collection.find({field:{$lte:value}});
//不等于: field != value
db.collection.find({field:{$ne:value}});
db.customer.count();
db.customer.find().count();
db.customer.find({age:{$lt:5}}).count();
db.customer.find().sort({age:1});
db.customer.find().skip(2).limit(3);
db.customer.find().sort({age:-1}).skip(2).limit(3);
db.customer.find().sort({age:-1}).skip(2).limit(3).count();
db.customer.find().sort({age:-1}).skip(2).limit(3).count(0);
db.customer.find().sort({age:-1}).skip(2).limit(3).count(1);
本文详细介绍MongoDB中各种查询条件的使用方法,包括大于、小于、等于、不等于等条件的实现方式,并展示了如何进行计数、排序、跳过指定数量的文档以及限制返回的文档数量等高级操作。
5907

被折叠的 条评论
为什么被折叠?



