本文总结了 mongoDB 中的查询和映射操作符。
具体使用方法可以单击操作符跳转查看
Query Selectors,查询操作符
Comparison,比较
For comparison of different BSON type values, see the specified
BSON comparison order.
| $eq | Matches values that are equal to a
specified value. | 
| $gt | Matches values that are greater than a
specified value. | 
| $gte | Matches values that are greater than or
equal to a specified value. | 
| $in | Matches any of the values specified in an
array. | 
| $lt | Matches values that are less than a
specified value. | 
| $lte | Matches values that are less than or equal
to a specified value. | 
| $ne | Matches all values that are not equal to a
specified value. | 
| $nin | Matches none of the values specified in an
array. | 
Logical,逻辑
| $and | Joins query clauses with a logical ANDreturns all documents that match the conditions of both
clauses. | 
| $not | Inverts the effect of a query expression
and returns documents that do not match the query
expression. | 
| $nor | Joins query clauses with a logical NORreturns all documents that fail to match both
clauses. | 
| $or | Joins query clauses with a logical ORreturns all documents that match the conditions of
either clause. | 
Element,单元
| $exists | Matches documents that have the specified
field. | 
| $type | Selects documents if a field is of the
specified type. | 
Evaluation,判断
| $expr | Allows use of aggregation expressions
within the query language. | 
| $jsonSchema | Validate documents against the given JSON
Schema. | 
| $mod | Performs a modulo operation on the value
of a field and selects documents with a specified result. | 
| $regex | Selects documents where values match a
specified regular expression. | 
| $text | Performs text search. | 
| $where | Matches documents that satisfy a
JavaScript expression. | 
Geospatial,地理空间
Array,数组
| $all | Matches arrays that contain all elements
specified in the query. | 
| $elemMatch | Selects documents if element in the array
field matches all the specified $elemMatchconditions. | 
| $size | Selects documents if the array field is a
specified size. | 
Bitwise,位
| $bitsAllClear | Matches numeric or binary values in which
a set of bit positions all have a value of 0. | 
| $bitsAllSet | Matches numeric or binary values in which
a set of bit positions all have a value of 1. | 
| $bitsAnyClear | Matches numeric or binary values in which
any bit from a set of bit positions has a value of 0. | 
| $bitsAnySet | Matches numeric or binary values in which
any bit from a set of bit positions has a value of 1. | 
Projection
Operators,映射操作符
| $ | Projects the first element in an array
that matches the query condition. | 
| $elemMatch | Projects the first element in an array
that matches the specified $elemMatchcondition. | 
| $meta | Projects the document's score assigned
during $textoperation. | 
| $slice | Limits the number of elements projected
from an array. Supports skip and limit slices. | 
Miscellaneous
Operators,其它操作符
| $comment | Adds a comment to a query predicate. | 
| $rand | Generates a random float between 0 and
1. | 
参考
Query
and Projection Operators