- Reference >
- Query, Update and Projection Operators
Query, Update and Projection Operators
Query Selectors
Comparison
Name | Description |
---|---|
$all | Matches arrays that contain all elements specified in the query. |
$gt | Matches values that are greater than the value specified in the query. |
$gte | Matches values that are equal to or greater than the value specified in the query. |
$in | Matches any of the values that exist in an array specified in the query. |
$lt | Matches values that are less than the value specified in the query. |
$lte | Matches values that are less than or equal to the value specified in the query. |
$ne | Matches all values that are not equal to the value specified in the query. |
$nin | Matches values that do not exist in an array specified to the query. |
Logical
Name | Description |
---|---|
$or | Joins query clauses with a logical OR returns all documents that match the conditions of either clause. |
$and | Joins query clauses with a logical AND returns 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 NOR returns all documents that fail to match both clauses. |
Element
Name | Description |
---|---|
$exists | Matches documents that have the specified field. |
$mod | Performs a modulo operation on the value of a field and selects documents with a specified result. |
$type | Selects documents if a field is of the specified type. |
JavaScript
Name | Description |
---|---|
$where | Matches documents that satisfy a JavaScript expression. |
$regex | Selects documents where values match a specified regular expression. |
Geospatial
Name | Description |
---|---|
$geoWithin | Selects geometries within a bounding GeoJSON geometry. |
$geoIntersects | Selects geometries that intersect with a GeoJSON geometry. |
$near | Returns geospatial objects in proximity to a point. |
$nearSphere | Returns geospatial objects in proximity to a point on a sphere. |
Array
Name | Description |
---|---|
$elemMatch | Selects documents if element in the array field matches all the specified $elemMatchcondition. |
$size | Selects documents if the array field is a specified size. |
Update Operators
Fields
Name | Description |
---|---|
$inc | Increments the value of the field by the specified amount. |
$rename | Renames a field. |
$setOnInsert | Sets the value of a field upon documentation creation during an upsert. Has no effect on update operations that modify existing documents. |
$set | Sets the value of a field in an existing document. |
$unset | Removes the specified field from an existing document. |
Array
Operators
Name Description $ Acts as a placeholder to update the first element that matches the query condition in an update. $addToSet Adds elements to an existing array only if they do not already exist in the set. $pop Removes the first or last item of an array. $pullAll Removes multiple values from an array. $pull Removes items from an array that match a query statement. $pushAll Deprecated. Adds several items to an array. $push Adds an item to an array.
Bitwise
Name | Description |
---|---|
$bit | Performs bitwise AND and OR updates of integer values. |
Isolation
Name | Description |
---|---|
$isolated | Modifies behavior of multi-updates to improve the isolation of the operation. |
Projection Operators
Name | Description |
---|---|
$ | Projects the first element in an array that matches the query condition. |
$elemMatch | Projects only the first element from an array that matches the specified $elemMatchcondition. |
$slice | Limits the number of elements projected from an array. Supports skip and limit slices. |
Meta-Query Operators
Query Modifiers
Name | Description |
---|---|
$comment | Adds a comment to the query to identify queries in the database profiler output. |
$explain | Forces MongoDB to report on query execution plans. See explain(). |
$hint | Forces MongoDB to use a specific index. See hint() |
$maxScan | Limits the number of documents a cursor will return for a query. See limit(). |
$max | Specifies a minimum exclusive upper limit for the index to use in a query. See max(). |
$min | Specifies a minimum inclusive lower limit for the index to use in a query. See min(). |
$orderby | Returns a cursor with documents sorted according to a sort specification. See sort(). |
$returnKey | Forces the cursor to only return fields included in the index. |
$showDiskLoc | Modifies the documents returned to include references to the on-disk location of each document. |
$snapshot | Forces the query to use the index on the _id field. See snapshot(). |
Sort Order Specifier
Name | Description |
---|---|
$natural | A special sort order that orders documents using the order of documents on disk. |
출처 - http://docs.mongodb.org/manual/reference/operator/
'DB > MongoDB' 카테고리의 다른 글
mongo - TTL (0) | 2014.01.15 |
---|---|
mongodb - 콜렉션 필드 형변환 (How to change the type of a field) (0) | 2013.10.07 |
mongodb - GridFS (0) | 2013.06.18 |
mongodb - binary data(type) 저장 (0) | 2013.06.18 |
mongodb - BSON(Binary JSON) (0) | 2013.06.18 |