mongodb查询的语法
本文参考自官方的手册: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-ConditionalOperators%3A%3C%2C%3C%3D%2C%3E%2C%3E%3D 1 ) . 大于,小于,大于或等于,小于或等于 $gt:大于 $lt:小于 $gte:大于或等于 $lte:小于或等于 例子:
db.collection.find({ "field" : { $gt: value } } ); // greater than : field > value
db.collection.find({ "field" : { $lt: value } } ); // less than : field < value db.collection.find({ "field" : { $gte: value } } ); // greater than or equal to : field >= value db.collection.find({ "field" : { $lte: value } } ); // less than or equal to : field <= value 如查询j大于3,小于4:
db.things.find({j : {$lt: 3}});
db.things.find({j : {$gte: 4}}); 也可以合并在一条语句内:
db.collection.find({ "field" : { $gt: value1, $lt: value2 } } ); // value1 < field < value
2) 不等于 $ne
|