当前位置:网站首页>MongoDB 常用查询语句
MongoDB 常用查询语句
2022-08-10 02:44:00 【Falling the bowie】
- 数据库工具:Navicat
- id :1-7 createTime是字符串类型,8-13 createTime是date类型

直接贴代码:
//查所有
db.getCollection("memberReadHistory").find()
//条件范围查询
db.getCollection('memberReadHistory').find({"memberId":3})
db.getCollection('memberReadHistory').find({"memberId":3,"productId":500})
db.getCollection('memberReadHistory').find({"memberId":{$gt:2}})
db.getCollection('memberReadHistory').find({"memberId":{$gt:2},"productId":500})
//使用 $and 多条件查询
db.getCollection('memberReadHistory').find({$and:[{"memberId":3},{"createTime":{$gte:"2022-08-07 14:38:00",$lte:"2022-08-07 14:40:00"}}]})
//时间字符串范围查询
db.getCollection('memberReadHistory').find({"memberId":3,"createTime":{$gte:'2022-08-07 14:38:00',$lte:'2022-08-07 14:40:00'}})
//date时间查询,ISODate("2022-08-07T07:22:44.375Z")
db.getCollection('memberReadHistory').find({$and:[{"memberId":3},{"createTime":{$gte:ISODate("2022-08-07T07:22:44.375Z")}}]})
边栏推荐
猜你喜欢

Robust Real-time LiDAR-inertial Initialization(实时鲁棒的LiDAR惯性初始化)论文学习

exchange2010 邮件数据库无法装入

flink 12 源码编译及使用idea运行、debug

Arcgis进阶篇(1)——安装Arcgis Enterprise,创建sde库

How to write a high-quality test case?

想要避免After Effects渲染失败的问题,5个小技巧必看

ArcGIS Advanced (1) - Install ArcGIS Enterprise and create an sde library

Example 048: Number ratio size

HACKTHEBOX——Bank

IDEA自动生成serialVersionUID
随机推荐
2022.8.8考试从记忆中写入(memory)题解
湖仓一体电商项目(四):项目数据种类与采集
基于误差状态的卡尔曼滤波ESKF
2022.8.9 Exam Travel Summary
flutter 每天一背,需要掌握
如何让导电滑环信号更好
socket编程基础
Little rookie Hebei Unicom induction training essay
2022.8.8考试摄像师老马(photographer)题解
实例042:变量作用域
【Kali安全渗透测试实践教程】第7章 权限提升
【Image Classification】2022-ConvMixer ICLR
如何使用腾讯字体,已经在什么场合下可以使用该字体?TTTGB-Medium
Robust Real-time LiDAR-inertial Initialization (Real-time Robust LiDAR Inertial Initialization) Paper Learning
【Kali安全渗透测试实践教程】第6章 密码攻击
Redis - Basic operations and usage scenarios of String|Hash|List|Set|Zset data types
Instance 042: Variable scope
如何编写一份优质的测试用例?
what is eabi
uni-app自定义导航栏