此操作符用于统计记录的中field的值小于等于value数据。用法如下面的代码所示:
db.collection.find({"field":{$lte:value}});
接下来举一个实际的例子,c1表的数据如下面的代码所示:
>db.c1.find() {"_id":ObjectId("4fb4af85afa87dc1bed94330"),"age":7,"length_1":30} {"_id":ObjectId("4fb4af89afa87dc1bed94331"),"age":8,"length_1":30} {"_id":ObjectId("4fb4af8cafa87dc1bed94332"),"age":6,"length_1":30}
查询age的值不等于8的数据,如下面的代码所示:
>db.c1.find({age:{$lte:7}}) {"_id":ObjectId("4fb4af85afa87dc1bed94330"),"age":7,"length_1":30} {"_id":ObjectId("4fb4af8cafa87dc1bed94332"),"age":6,"length_1":30}
可以看出,只显示age小于等于7的数据,age等于8的数据没有显示出来。