// mongodb的查询真让人难以琢磨,就查询单天信息,都需要花费一番功夫才行。 // 第一种方式: coll.aggregate([ {$project:{sendDate: {$substr: ['$sendTime', 0, 10]}, sendTime: 1, content:1}}, {$match:{sendDate: '2015-07-05'}}, ]) // 第二种方式(第二种的变异): coll.aggregate([ {$match: {'sendTime': {'$gte': new Date('2015-07-05'), '$lt': new Date('2015-07-06')}}} // 第三中方式(第二种的变异): coll.aggregate([ {$match: {'sendTime': {'$gte': new Date('2015-07-05 00:00:00'), '$lte': new Date('2015-07-05 23:59:59')}}}
// 查询结果如下(展示一种方式:其他展示略有不同): [ { _id: 5599b09bc16aac90e9fb7995, sendDate: '2015-07-05' }, { _id: 5599b161c16aac90e9fb7996, sendDate: '2015-07-05' }, { _id: 5599b161c16aac90e9fb7997, sendDate: '2015-07-05' } ]
$cmp | Returns: 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second. |
$eq | Returns true if the values are equivalent. |
$gt | Returns true if the first value is greater than the second. |
$gte | Returns true if the first value is greater than or equal to the second. |
$lt | Returns true if the first value is less than the second. |
$lte | Returns true if the first value is less than or equal to the second. |
$ne | Returns true if the values are not equivalent. |
相关推荐
如果您不习惯MongoDB查询语言,那么Studio3T的SQL查询可能会派上用场。编写SQL选择表达式和SQL联接来查询mongodb,并查看SQL查询如何转换为MQL——这是一个很好的工具。SQL查询语言
主要介绍了Thinkphp使用mongodb数据库实现多条件查询方法,修改了mongodb驱动文件来实现复合查询、多条件查询,需要的朋友可以参考下
NoSQL数据库之MongoDB查询
mongodb 常用查询语法包括分页等用法
MongoDB高级查询用法大全
MongoDB命令查询.txt
主要介绍了使用aggregate在MongoDB中查询重复数据记录的方法的相关资料,需要的朋友可以参考下
很全面的mongodb 查询语法和实例 $gt $lt $gte $lte $exists $size $type 等等
一、MongoDB简介 3 二、MongoDB结构 3 二、MongoDB 数据库关系型(这里并不是值关系型数据库的关系) 3 1、MongoDB一对一关系型 3 2、MongoDB一对多关系型 4 3、MongoDB多对多关系型 4 三、创建数据库(mongodb_test...
MongoDB基本查询.pdf 学习资料 复习资料 教学资源
MongoDB高级查询,许多有用的查询函数,相信大家会用得到的
mongodb查询数据,显示DBCursor.next这种形式,那如何把值带到JSP显示呢? 上传的是一个项目Demo,导入可以直接运行,当然也可以直接查看其中的代码。 项目是使用jquery.ajax显示后台返回的Json串。 若再详细了解...
生成mongodb日期范围查询条件
MongoDB 位置信息存储及查询,批量插入或更新位置信息,查询位置点是否在指定区域内(圆形区域、矩形区域、多边形区域)。
文档详细描述了MongoDB使用find或者findOne时的shell查询语法,对于掌握mongoDB是非常有用的
介绍php7.0以上使用mongdb的基本方法,并提供mongodb随机获取一条记录的测试实例。
MongoDB基本的语法
Mastering MongoDB 3.x: An expert’s guide to building fault-tolerant MongoDB applications MongoDB has grown to become the de facto NoSQL database with millions of users—from small startups to Fortune...
MongoDB之查询
真实有效的mongodb视频教程地址 深入浅出 MongoDB 高清IT教程视频下载 1.1、-nosql与MongoDB.mp4 1.2、-MongoDB安装配置.mp4 1.3、-MongoDB?shell详.mp4 1.4、-MongoDB文档、集合、... 2.4、-MongoDB查询语法3.mp4