• Reference > 
  • Query, Update and Projection Operators

Query, Update and Projection Operators

Query Selectors

Comparison

NameDescription
$allMatches arrays that contain all elements specified in the query.
$gtMatches values that are greater than the value specified in the query.
$gteMatches values that are equal to or greater than the value specified in the query.
$inMatches any of the values that exist in an array specified in the query.
$ltMatches values that are less than the value specified in the query.
$lteMatches values that are less than or equal to the value specified in the query.
$neMatches all values that are not equal to the value specified in the query.
$ninMatches values that do not exist in an array specified to the query.

Logical

NameDescription
$orJoins query clauses with a logical OR returns all documents that match the conditions of either clause.
$andJoins query clauses with a logical AND returns all documents that match the conditions of both clauses.
$notInverts the effect of a query expression and returns documents that do not match the query expression.
$norJoins query clauses with a logical NOR returns all documents that fail to match both clauses.

Element

NameDescription
$existsMatches documents that have the specified field.
$modPerforms a modulo operation on the value of a field and selects documents with a specified result.
$typeSelects documents if a field is of the specified type.

JavaScript

NameDescription
$whereMatches documents that satisfy a JavaScript expression.
$regexSelects documents where values match a specified regular expression.

Geospatial

NameDescription
$geoWithinSelects geometries within a bounding GeoJSON geometry.
$geoIntersectsSelects geometries that intersect with a GeoJSON geometry.
$nearReturns geospatial objects in proximity to a point.
$nearSphereReturns geospatial objects in proximity to a point on a sphere.

Array

NameDescription
$elemMatchSelects documents if element in the array field matches all the specified $elemMatchcondition.
$sizeSelects documents if the array field is a specified size.

Update Operators

Fields

NameDescription
$incIncrements the value of the field by the specified amount.
$renameRenames a field.
$setOnInsertSets the value of a field upon documentation creation during an upsert. Has no effect on update operations that modify existing documents.
$setSets the value of a field in an existing document.
$unsetRemoves the specified field from an existing document.

Array

Operators

NameDescription
$Acts as a placeholder to update the first element that matches the query condition in an update.
$addToSetAdds elements to an existing array only if they do not already exist in the set.
$popRemoves the first or last item of an array.
$pullAllRemoves multiple values from an array.
$pullRemoves items from an array that match a query statement.
$pushAllDeprecated. Adds several items to an array.
$pushAdds an item to an array.

Modifiers

NameDescription
$eachModifies the $push and $addToSet operators to append multiple items for array updates.
$sliceModifies the $push operator to limit the size of updated arrays.
$sortModifies the $push operator to reorder documents stored in an array.

Bitwise

NameDescription
$bitPerforms bitwise AND and OR updates of integer values.

Isolation

NameDescription
$isolatedModifies behavior of multi-updates to improve the isolation of the operation.

Projection Operators

NameDescription
$Projects the first element in an array that matches the query condition.
$elemMatchProjects only the first element from an array that matches the specified $elemMatchcondition.
$sliceLimits the number of elements projected from an array. Supports skip and limit slices.

Meta-Query Operators

Query Modifiers

NameDescription
$commentAdds a comment to the query to identify queries in the database profiler output.
$explainForces MongoDB to report on query execution plans. See explain().
$hintForces MongoDB to use a specific index. See hint()
$maxScanLimits the number of documents a cursor will return for a query. See limit().
$maxSpecifies a minimum exclusive upper limit for the index to use in a query. See max().
$minSpecifies a minimum inclusive lower limit for the index to use in a query. See min().
$orderbyReturns a cursor with documents sorted according to a sort specification. See sort().
$returnKeyForces the cursor to only return fields included in the index.
$showDiskLocModifies the documents returned to include references to the on-disk location of each document.
$snapshotForces the query to use the index on the _id field. See snapshot().

Sort Order Specifier

NameDescription
$naturalA 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 - Query, Update and Projection Operators  (0) 2013.07.23
    mongodb - GridFS  (0) 2013.06.18
    mongodb - binary data(type) 저장  (0) 2013.06.18
    mongodb - BSON(Binary JSON)  (0) 2013.06.18
    Posted by linuxism

    댓글을 달아 주세요