One - One Code All

Blog Content

MongoDB查询小结 - find【查询条件$lt $lte $gt $gte】

Nosql   2016-08-15 20:35:01

MongoDB查询小结 - find【查询条件$lt $lte $gt $gte】


$lt $lte $gt $gte


以上四个分别表示为:< 、 <= 、 > 、 >= 。 通常的做法是将他们组合起来,以便查找一个范围。 比如,查询年龄在18到25岁(含)的人,我们可以这样


db.user.find({"age":{"$gte":18,"$lte":25}})


这样的范围查询对查询日期特别有用 比如,查询在2015年1月1日后注册的用户


start = new Date("01/01/2015") 

db.user.find({"register":{"$gte":start}})



上一篇:MongoDB初步使用
下一篇:RabbitMQ的安装和配置化可视界面

The minute you think of giving up, think of the reason why you held on so long.