mongo find
MongoVUE

对应成语句,结构如下:
db.logs.find({ "message" : /消息/ }, { "message" : 1 }).limit(50).sort({ "timestamp" : -1 });
现有学生表(姓名,年龄,时间)
create table student
(
NAME VARCHAR2(100),
AGE NUMBER(2),
CREATETIME TIMESTAMP(6)
)
1. 检索全部
select * from student
db.student.find({ });
2. 检索某些字段(0:不存在,1:存在),存在模式下只显示指定的字段,不存在模式下不显示指定的字段
select name from student
db.student.find({ }, { "name" : 0 })
3.排序(-1:desc, 1:asc)
select * from student order by age desc
db.student.find({ }).sort({ "age" : -1 });
4.值等
select * from student where name='小明'
db.student.find({ "name" : "小明" });
5.like
select * from student where name like '%旭%'
db.student.find({ "name" : /旭/ });
6.and
select * from student where name like '%旭%' and age =22
db.student.find({ "name":/旭/,"age":22});
7.or
select * from student where name like '%旭%' or age=22
db.student.find({ "$or" : [{ "name" : /旭/ }, { "age" : 22 }] });
8.<, <=, >, >= ($lt, $lte, $gt, $gte )
select * from student where age >=18 and age <=20
db.student.find({ "age" : { "$gte" : 18,"$lte" : 20 } });
9. 日期比较大小(Mongodb 中 Type 为 DateTime)
select * from student where createtime >= to_date('2015-06-01 10:10:10','YYYY-MM-DD HH24:MI:SS')
db.student.find({"createtime":{"$gte":ISODate("2015-06-01T10:10:10Z")}});
ps:中国+8 时区,mongodb 0 时区 (db)
查询时要以0时区为准(+8时间-8小时)
mongo find的更多相关文章
- 谈一谈NOSQL的应用,Redis/Mongo
1.心路历程 上年11月份来公司了,和另外一个同事一起,做了公司一个移动项目的微信公众号,然后为了推广微信公众号,策划那边需要我们做一些活动,包括抽奖,投票.最开始是没有用过redis的,公司因为考虑 ...
- MongoDB分组汇总操作,及Spring data mongo的实现
转载请在页首注明作者与出处 一:分组汇总 1.1:SQL样例 分组汇总的应用场景非常多,比如查询每个班级的总分是多少,如果用关系形数据库,那么sql是这样子的 ),class from score g ...
- mongo DB for C#
(1)Download the MongoDB C#驱动. http://www.nuget.org/packages/mongocsharpdriver/. (2) Add Reference to ...
- Mongo基础使用,以及在Express项目中使用Mongoose
MongoDB的基本使用 MongoDB特点: 使用BSON存储数据 支持相对丰富的查询操作(相对其他nosql数据库) 支持索引 副本集(支持多个实例/多个服务器运行同个数据库) 分片(数据库水平扩 ...
- 【mongo】mongoVUE使用
1.查询存在字段"test"的项 {"test":{$exists:true}} 2.在表中插入字段 {$set:{"}} 3.正则匹配 {" ...
- mongo遍历表
$mongo = new MongoClient("mongodb://192.168.8.189:27017"); $collectObj = $mongo->select ...
- python & mongo问题记录
背景介绍 使用python操作mongo进行的一些操作记录,为了方便日后可以快速的解决类似问题. 准备工作 为了尽可能简单的说明,我将插入几条简单的数据. from pymongo import Mo ...
- Lind.DDD.Repositories.Mongo层介绍
回到目录 之前已经发生了 大叔之前讲过被仓储化了的Mongodb,而在大叔开发了Lind.DDD之后,决定把这个东西再搬到本框架的仓储层来,这也是大势所趋的,毕竟mongodb是最像关系数据库的NoS ...
- MongoDB基础入门003--使用官方驱动操作mongo,C#
本篇先简单介绍一下,使用官方驱动来操作MongoDB.至于MongoDB原生的增删改查语句,且等以后再慢慢学习. 一.操作MongoDB的驱动主要有两个 1.官方驱动:https://github.c ...
- mongo DB的一般操作
最近接触了一些mongoDB .将一些指令操作记录下来,便于查询和使用 登录 [root@logs ~]# mongo -u loguser -p log123456 --authentication ...
随机推荐
- /etc/sysctl.conf参数解释(转)
来自<深入理解Nginx模块开发与架构解析> P9 #表示进程(例如一个worker进程)可能同时打开的最大句柄数,直接限制最大并发连接数fs.file max = 999999 #1代表 ...
- Java 权限框架 Shiro 实战一:理论基础
Apache Shiro 官网地址:http://shiro.apache.org/ Apache Shiro is a powerful and easy-to-use Java security ...
- [正经分析] DAG上dp两种做法的区别——拓扑序与SPFA
在下最近刷了几道DAG图上dp的题目. 要提到的第一道是NOIP原题<最优贸易>.这是一个缩点后带点权的DAG上dp,它同时规定了起点和终点. 第二道是洛谷上的NOI导刊题目<最长路 ...
- 马士兵Spring-声明式事务管理-annotation
1.事务加在DAO层还是service层? service中可能多涉及多种DAO的操作,比如存了一个User之后,需要保存一条日志信息:如果在DAO中分别设置事务的话,一个DAO下面方法抛出异常了,但 ...
- mac电脑安装selenium 记录
1.使用终端去命令安装 sudo easy_install selenium 参考:https://www.cnblogs.com/nichoc/p/5543654.html 2.听说驱动放在 /us ...
- Pthreads n 体问题
▶ <并行程序设计导论>第六章中讨论了 n 体问题,分别使用了 MPI,Pthreads,OpenMP 来进行实现,这里是 Pthreads 的代码,分为基本算法和简化算法(引力计算量为基 ...
- 263. Ugly Number + 264. Ugly Number II + 313. Super Ugly Number
▶ 三个与丑数相关的问题 ▶ 第 263题,判定一个数字是否是丑数,即其素因子是否仅由 2,3,5 构成. ● 常规消除判别,4 ms class Solution { public: bool is ...
- ORA-12528问题解决
这个问题说明数据库没有Mount 最好先将系统日志一并清空,避免以下报错信息: ERROR:ORA-28056: Writing audit records to Windows Event Log ...
- 11 MySQL--Navicat与pymysql模块
1.Navicat的安装下载 一.Navicat 在生产环境中操作MySQL数据库还是推荐使用命令行工具mysql,但在我们自己开发测试时, 可以使用可视化工具Navicat,以图形界面的形式操作My ...
- vue.js常见面试题及常见命令介绍
Vue.js介绍 Vue.js是JavaScript MVVM(Model-View-ViewModel)库,十分简洁,Vue核心只关注视图层,相对AngularJS提供更加简洁.易于理解的API.V ...