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 ...
随机推荐
- Javaweb经典三层架构的演变
1.Javaweb经历了三个时期 ①JSP Model1第一代 JSP Model1是JavaWeb早期的模型,它适合小型Web项目,开发成本低!Model1第一代时期,服务器端只有JSP页面,所有的 ...
- Non-standard evaluation, how tidy eval builds on base R
As with many aspects of the tidyverse, its non-standard evaluation (NSE) implementation is not somet ...
- 走迷宫(用队列bfs并输出走的路径)
#include <iostream> #include <stack> #include <string.h> #include <stdio.h> ...
- [MVC 4] ActionResult 使用示例
在控制器 HomeController.cs 中使用以下代码 public ActionResult Contact() { ViewBag.Message = "Your contact ...
- 符合RESTful规范的API
统一使用的utils,serializers: class BaseResponse: def __init__(self): self.code = 1000 self.data = None se ...
- 好记性不如烂笔头-linux学习笔记1
好记性不如烂笔头-linux学习笔记1 linux的文件系统有ext2,ext3,ext4,目前主流是ext4 linux主要用于服务器级别的操作系统,安装时需要至少2个分区 一个是交换分区,swap ...
- Centos 7.2基础安装和配置(含分区方案建议)
景:windows桌面运维为主的我,前几天接到一个去某客户上架安装服务器的工作任务,含糊的说要上架几台服务器顺便安装Centos系统,于是我便下载了一个Centos7.2版本的镜像,顺利的用USBwr ...
- leetcode561
public class Solution { public int ArrayPairSum(int[] nums) { var list = nums.OrderBy(x => x).ToL ...
- How do I list subversion repository's ignore settings
If it is Windows and you are using TortoiseSVN, then right-click on a folder of the working copy, go ...
- java编写binder服务实例
文件目录结果如下: 一. 编写AIDL文件 IHelloService.aidl: /** {@hide} */ interface IHelloService { void sayhello(); ...