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. 悦读FM客户端应用源码

    <ignore_js_op> <ignore_js_op><ignore_js_op> 正如悦读FM所表达的[当好的文字遇上好的声音],悦读FM提供了一个很好的文章 ...

  2. UVA1001 Say Cheese (dijkstra)

    如果没有洞,那么任意两点的最短距离就是直线距离,洞里是瞬间的,所以看成一个点就行了(其实点也可以当作半径为0的洞来处理),洞到洞的最短距离都是圆心距离减去半径.剩下的就是求单源最短路径,是完全图,用不 ...

  3. java解析sql文件

    package com.athena.ckx.util; import java.io.FileInputStream; import java.io.InputStream; import java ...

  4. GYM 101604 || 20181010

    看着前面咕咕咕的国庆集训 难受 十月十日要萌一天哇www A.字符串 题意:给定一个字符串 问能否交换两个字符或者不交换字符,使其成为回文串 之前写的太丑 重写一遍加一堆 if 竟然过了w 思路:求出 ...

  5. 毛毛虫组【Beta】Scrum Meeting 3

    第三天 日期:2019/6/25 前言 第三次会议: 时间:6月25日 地点:教10-A511 内容:此次会议主要是对项目验收做准备工作. 1.1 今日完成任务情况以及遇到的问题. 今日完成任务情况: ...

  6. linux的less命令

    less 在查看之前不会加载整个文件.可以尝试使用 less 和 vi 打开一个很大的文件,你就会看到它们之间在速度上的区别. 在 less 中导航命令类似于 vi.本文中将介绍一些导航命令以及使用 ...

  7. python 连接redis cluster

    #!/usr/bin/env python # encoding: utf-8 #@author: 东哥加油! #@file: clear_pool.py #@time: 2018/8/28 17:0 ...

  8. 力扣题目汇总(重复N次元素,反转字符串,斐波那契数)

    重复 N 次的元素 1.题目描述 在大小为 2N 的数组 A 中有 N+1 个不同的元素,其中有一个元素重复了 N 次. 返回重复了 N 次的那个元素. 示例 1: 输入:[1,2,3,3] 输出:3 ...

  9. 图像分割loss集合

    我们只是大佬的搬运工 1.log loss 2.WBE loss 带权重的交叉熵 3.Focal loss 容易过拟合?我在VGG16上做过实验(没有BN层),发现网络在训练集上的性能直线上升,但是验 ...

  10. python面向对象(反射)(四)

    1. isinstance, type, issubclass isinstance: 判断你给对象是否是xx类型的. (向上判断 type: 返回xxx对象的数据类型 issubclass: 判断x ...