Saturday, January 13, 2018

MongoDB Basics - Querying MongoDB


Query MethodDescription
db.collection.find()Performs a query on a collection and returns a cursor object.
db.collection.findAndModify()Atomically modifies and returns a single document.
db.collection.findOne()Performs a query and returns a single document ... the first one found by natural search order.
db.collection.findOneAndDelete()Finds a single document and deletes it.
db.collection.findOneAndReplace()Finds a single document and replaces it.
db.collection.findOneAndUpdate()Finds a single document and updates it.



NameDescription
$eqMatches values that are equal to a specified value.
$gtMatches values that are greater than a specified value.
$gteMatches values that are greater than or equal to a specified value.
$ltMatches values that are less than a specified value.
$lteMatches values that are less than or equal to a specified value.
$neMatches all values that are not equal to a specified value.
$inMatches any of the values specified in an array.
$ninMatches none of the values specified in an array.
$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.
$existsMatches documents that have the specified field.
$typeSelects documents if a field is of the specified type.
$modPerforms a modulo operation on the value of a field and selects documents with a specified result.
$regexSelects documents where values match a specified regular expression.
$textPerforms text search.
$whereMatches documents that satisfy a JavaScript expression.
$geoWithinSelects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.
$geoIntersectsSelects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects.
$nearReturns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2dindexes support $near.
$nearSphereReturns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphereand 2d indexes support $nearSphere.
$allMatches arrays that contain all elements specified in the query.
$elemMatchSelects documents if element in the array field matches all the specified $elemMatch conditions.
$sizeSelects documents if the array field is a specified size.
$bitsAllSetMatches numeric or binary values in which a set of bit positions all have a value of 1.
$bitsAnySetMatches numeric or binary values in which any bit from a set of bit positions has a value of 1.
$bitsAllClearMatches numeric or binary values in which a set of bit positions all have a value of 0.
$bitsAnyClearMatches numeric or binary values in which any bit from a set of bit positions has a value of 0.
$commentAdds a comment to a query predicate.
$Projects the first element in an array that matches the query condition.
$elemMatchProjects the first element in an array that matches the specified $elemMatch condition.
$metaProjects the document’s score assigned during $text operation.
$sliceLimits the number of elements projected from an array. Supports skip and limit slices.

No comments:

Post a Comment

உப்பு மாங்காய்

சுருக்குப்பை கிழவி. சுருக்கங்கள் சூழ் கிழவி. பார்க்கும் போதெல்லாம் கூடையுடனே குடியிருப்பாள். கூடை நிறைய குட்டி குட்டி மாங்காய்கள். வெட்டிக்க...