1 $unset

The $unset operator deletes a particular field。

https://docs.mongodb.com/manual/reference/operator/update/unset/

2 $in

The $in operator selects the documents where the value of a field equals any value in the specified array。

https://docs.mongodb.com/manual/reference/operator/query/in/

3 $nin

Syntax: { field: { $nin: [ <value1>, <value2> ... <valueN> ]} }

$nin selects the documents where:

the field value is not in the specified array or
the field does not exist.

https://docs.mongodb.com/manual/reference/operator/query/nin/

3 $slice

The $slice operator controls the number of items of an array that a query returns.

https://docs.mongodb.com/manual/reference/operator/projection/slice/

4 $all

The $all operator selects the documents where the value of a field is an array that contains all the specified elements.

https://docs.mongodb.com/manual/reference/operator/query/all/

5 $and

Syntax: { $and: [ { <expression1> }, { <expression2> } , ... , {<expressionN> } ] }

db.inventory.find( { $and: [ { price: { $ne: 1.99 } }, { price: { $exists: true } } ] } )

$and performs a logical AND operation on an array of two or more expressions (e.g. <expression1><expression2>, etc.) and selects the documents that satisfy all the expressions in the array.

https://docs.mongodb.com/manual/reference/operator/query/and/

6 $match

Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

The $match stage has the following prototype form:

{ $match: { <query> } }
db.articles.aggregate(
[ { $match : { author : "dave" } } ]
);

7 $group

https://docs.mongodb.com/manual/reference/operator/aggregation/group/

示例:

  

for i in col.find().limit():
print(i)
{'_id': ObjectId('5698f524a98063dbe9e91ca8'), 'pub_date': '2016-01-12', 'look': '-', 'area': '朝阳', 'title': '【图】95成新小冰柜转让 - 朝阳高碑店二手家电 - 北京58同城', 'url': 'http://bj.58.com/jiadian/24541664530488x.shtml', 'cates': ['北京58同城', '北京二手市场', '北京二手家电', '北京二手冰柜'], 'price': '450 元'}
{'_id': ObjectId('5698f525a98063dbe4e91ca8'), 'pub_date': '2016-01-14', 'look': '-', 'area': '朝阳', 'title': '【图】洗衣机,小冰箱,小冰柜,冷饮机 - 朝阳定福庄二手家电 - 北京58同城', 'url': 'http://bj.58.com/jiadian/24349380911041x.shtml', 'cates': ['北京58同城', '北京二手市场', '北京二手家电', '北京二手洗衣机'], 'price': '1500 元'}
{'_id': ObjectId('5698f525a98063dbe7e91ca9'), 'pub_date': '2015-12-27', 'look': '9成新', 'area': '朝阳', 'title': '台式主机转让 - 朝阳孙河台式机/配件 - 北京58同城', 'url': 'http://bj.58.com/diannao/24440805710645x.shtml', 'cates': ['北京58同城', '北京二手市场', '北京二手台式机/配件', '北京二手台式机'], 'price': ''}

  1

pipeline1 = [
{'$match':{'$and':[{'pub_date':{'$gt':'2016-01-02','$lt':'2016-01-15'}},{'area':{'$all':['昌平']}}]}},
{'$group':{'_id':{'$slice':['$cates',,]},'count':{'$sum':}}},
{'$sort':{'count':-}},
{'$limit':},
]

  2

pipeline2 = [
{'$match':{'$and':[{'pub_date':{'$gt':'2016-01-02','$lt':'2016-01-15'}},{'look':{'$nin':['-']}}]}},
{'$group':{'_id':'$look','avg_price':{'$max':'$price'}}},
{'$sort':{'avg_price':-}},
{'$limit':},
]

mongo 操作符的更多相关文章

  1. [Mongo] 解决mongoose不支持条件操作符 $gt$gte:$lte$ne $in $all $not

    reference : http://blog.sina.com.cn/s/blog_4df23d840100u25x.html 找到mongoose的安装目录 /usr/local/lib/node ...

  2. Mongo DB 2.6 需要知道的一些自身限定

    在现实的世界中,任何事情都有两面性,在程序的世界中,亦然! 我们不论是在使用一门新的语言,还是一门新的技术,在了解它有多么的让人兴奋,让人轻松,多么的优秀之余,还是很有必要了解一些他的局限性,方便你在 ...

  3. segmentfault.com mongo出识以及对数组的操作

    https://segmentfault.com/a/1190000003951602 首先推荐个工具,no-sql-manager-for-mongodb-professional,虽然收费,但是每 ...

  4. Mongo中的数组操作

    当前mongo中有这么一条数据 book是一个数组,在他后面添加一条数据 { "_id" : ObjectId("5721f504d1f70435632b5ce7&quo ...

  5. mongo 学习笔记

    mysql语句 : ' ,,),(,,)   mongo语句: db.}}).limit() db."}) db.}}) 条件操作符1 mongodb中的条件操作符有: (>) 大于 ...

  6. mongo数据库基础操作

    概念 一个mongod服务可以有建立多个数据库,每个数据库可以有多张表,这里的表名叫collection,每个collection可以存放多个文档(document),每个文档都以BSON(binar ...

  7. Mongo 专题

    什么是MongoDB ? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统. 在高负载的情况下,添加更多的节点,可以保证服务器性能. MongoDB 旨在为WEB应用提供 ...

  8. mongo中的游标与数据一致性的取舍

    除了特殊注释外,本文的测试结果均基于 spring-data-mongodb:1.10.6.RELEASE(spring-boot-starter:1.5.6.RELEASE),MongoDB 3.0 ...

  9. spring-data-mongodb与mongo shell的对应关系

    除了特殊注释外,本文的测试结果均基于 spring-data-mongodb:1.10.6.RELEASE(spring-boot-starter:1.5.6.RELEASE),MongoDB 3.0 ...

随机推荐

  1. COGS 1786. 韩信点兵

    ★★★   输入文件:HanXin.in   输出文件:HanXin.out   简单对比时间限制:1 s   内存限制:256 MB [题目描述] 韩信是中国军事思想“谋战”派代表人物,被后人奉为“ ...

  2. Java简答题附答案

    1. Java有没有goto? 有, Goto语句在java中作为保留字, 并没有实现它. 带标号的break, continue局限于循环体中跳转 带标号的goto可以在一个函数(c语言)中任意跳转 ...

  3. POI写入word docx 07 的两种方法

    下载最新jar包:http://poi.apache.org/download.html 以及API 1.写入word 1.1 直接通过XWPFDocument生成 在使用XWPFDocument写d ...

  4. 设置section的距离

    在ios7中使用group类型的tableview时,第一个section距离navigationbar的距离很大,不符合这边的设计图.使用 myTableView . sectionHeaderHe ...

  5. Xcode的Git管理

    在Xcode中创建工程的时候,我们很容易的可以将新创建的工程添加到Git中,如图: 但是如果是本地已经有的工程,那该如何添加到Git中呢? 首先终端进入到该工程的目录. 然后: git init gi ...

  6. Java 的访问权限

    public>protected>默认(包访问权限)>private,因为protected除了可以被同一包访问,还可以被包外的子类所访问

  7. UNIX环境C语言进程通信

    一.信号管理 1.函数signal signal函数是UNIX系统信号机制最简单的接口 #include <signal.h> typedef void (*sighandler_t)(i ...

  8. Linux中文件压缩与解压

    压缩与解压 compress 文件名 1 -v //详细信息 2 3 -d //等于 uncompress 默认只识别 .Z 如果使用别的后缀,会导致不识别,解压缩失败.也可以使用 -d -c 压缩包 ...

  9. selenium.common.exceptions.WebDriverException: Message: u'unknown error: cannot get automation extension\nfrom unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfeb

    Python2.7 selenium3.4.1在使用chrome driver时报错:selenium.common.exceptions.WebDriverException: Message: u ...

  10. u-boot顶层Makefile分析

    1.u-boot制作命令 make forlinx_nand_ram256_config: make all; 2.顶层mkconfig分析,参考 U-BOOT顶层目录mkconfig分析 mkcon ...