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. codevs 2277 爱吃皮蛋的小明(水题日常)

    时间限制: 1 s  空间限制: 32000 KB  题目等级 : 白银 Silver 题目描述 Description 小明特别爱吃蛋,特别是皮蛋.他一次可以吃一个蛋或者两个蛋(整个吞下去),而且他 ...

  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource

    spring boot web项目运行时提示如下错误 org.springframework.beans.factory.BeanCreationException: Error creating b ...

  3. mvc的model验证,ajaxhelper,验证机制语法

    ajaxhelper: onsuccess是调用成功后显示方法,还有一个方法是调用前显示 model验证: 控件前端验证: 需要引入的JS 其中第二个是ajaxhelper的必须验证 后台的两个同名不 ...

  4. 2018_oakland_linuxmalware

    2018年oakland论文:理解linux恶意软件 论文地址:http://www.s3.eurecom.fr/~yanick/publications/2018_oakland_linuxmalw ...

  5. stringstream clear与str("")的问题

    一.str与clear函数 C++Reference对于两者的解释: 可见:clear()用来设置错误状态,相当于状态的重置:str用来获取或预置内容 二.区别 运行下面测试代码: #include& ...

  6. FIBON高精度

    #include<stdio.h> #include<string.h> int u,n; ],b[],h[]; ],y[],z[]; int main() { char s( ...

  7. python小括号( )与中括号 [ ]

    在python中小括号()表示的是tuple元组数据类型,元组是一种不可变序列. >>> a = (1,2,3) >>> a (1, 2, 3) >>& ...

  8. Linux文件操作函数

    creat() 函数 close() 函数 read() 函数 read 函数实际读到的字节数少于要求读的字节数时: 读普通文件,在读到要求字节数之前就到达文件尾: 当从终端设备读,通常一次最多读一行 ...

  9. centos7 samba配置完成后不管怎么登陆都会显示密码错误的解决方案

    添加系统用户 useradd samba 添加samba用户 smbpasswd -a samba 激活samba用户 smbpasswd -e samba 1.win+r运行secpol.msc打开 ...

  10. PHP 把字符转换为 HTML 实体 - htmlentities() 函数

    定义和用法 htmlentities() 函数把字符转换为 HTML 实体. 语法 htmlentities(string,quotestyle,character-set) 参数 描述 string ...