比较操作符
Name | Description |
---|
$eq | 匹配等于指定值的值 |
$gt | 匹配大于指定值的值 |
$gte | 匹配大于或等于指定值的值 |
$lt | 匹配小于指定值的值 |
$lte | 匹配小于或等于指定值的值 |
$ne | 匹配不等于指定值的所有值 |
$in | 匹配数组中指定的任何值 |
$nin | 不匹配数组中指定的值 |
逻辑操作符
Name | Description |
---|
$or | 使用逻辑OR连接查询子句将返回符合任一子句条件的所有文档 |
$and | 使用逻辑AND连接查询子句将返回符合两个子句条件的所有文档 |
$not | 颠倒查询表达式的效果并返回与查询表达式不匹配的文档 |
$nor | 用逻辑NOR连接查询子句返回所有不能匹配这两个子句的文档 |
元素(Element)操作符
Name | Description |
---|
$exists | 匹配具有指定字段的文档 |
$type | 如果某个字段是指定类型,则选择文档 |
值(Evaluation)操作符
Name | Description |
---|
$mod | 对字段的值执行模运算,并选择具有指定结果的文档 |
$regex | 选择值与指定正则表达式匹配的文档 |
$text | 执行文本搜索 |
$where | 匹配满足JavaScript表达式的文档 |
Geospatial (地球几何空间操作符?这个真看不懂了,贴官方原文)
Name | Description |
---|
$geoWithin | Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin. |
$geoIntersects | Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects. |
$near | Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near. |
$nearSphere | Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere. |
数组操作符
Name | Description |
---|
$all | 匹配包含查询中指定的所有元素的数组 |
$elemMatch | 如果数组中的元素与所有指定的条件匹配,则选择文档 |
$size | 如果数组字段为指定大小,则选择文档 |
二进制操作符(不太会用,帖原文)
Name | Description |
---|
$bitsAllSet | Matches numeric or binary values in which a set of bit positions all have a value of 1. |
$bitsAnySet | Matches numeric or binary values in which any bit from a set of bit positions has a value of 1. |
$bitsAllClear | Matches numeric or binary values in which a set of bit positions all have a value of 0. |
$bitsAnyClear | Matches numeric or binary values in which any bit from a set of bit positions has a value of 0. |
Name | Description |
---|
$comment | Adds a comment to a query predicate. |
映射操作符
Name | Description |
---|
$ | 在与查询条件匹配的数组中比配的第一个元素 |
$elemMatch | 映射数组中与匹配指定的$elemMatch条件的第一个元素 |
$meta | Projects the document’s score assigned during $text operation.(在文本操作期间分配文档的评分?这个不太明白) |
$slice | 限制从数组中投射的元素的数量。支持跳过和限制切片(相当于分页) |
官方原文:http://www.mongoing.com/docs/reference/operator/query.html