- $eq Matches values that are equal to the value specified in the query.
- $gt Matches values that are greater than the value specified in the query.
- $gte Matches values that are greater than or equal to the value specified in the query.
"age" $gt 18
"age" $gte 18
- $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.
"age" $lt 18
"age" $lte 18
- $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.
- $or Joins query clauses with a logical OR returns all documents that match the conditions of either clause.
$or("qty" $lt 20 $gte 10, "sale" $eq true)
- $and Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
$and("name" $eq "foo", "surname" $eq "bar", "age" $eq 32)
- $not Inverts the effect of a query expression and returns documents that do not match the query expression.
"price" $not { _ $gte 5.1 }
- $nor Joins query clauses with a logical NOR returns all documents that fail to match both clauses.
$nor("price" $eq 1.99, "qty" $lt 20, "sale" $eq true)
- $exists Matches documents that have the specified field.
"qty" $exists true
"qty" $exists false
- $type Selects documents if a field is of the specified type.
"qty".$type[BSONDouble]
"qty".$type[BSONNull.type]
- $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.
"name" $regex ("^Al.*", "i")
- $text Performs text search.
$text("bake coffee cake")
$text("bake coffee cake", "turkish")
- $where Matches documents that satisfy a JavaScript expression.
$where("function () { this.credits == this.debits }")
- $all Matches arrays that contain all elements specified in the query.
"size" $all ("S", "M", "L")
- $elemMatch Selects documents if element in the array field matches all the specified $elemMatch condition.
"array" $elemMatch ("value1" $eq 1, "value2" $gt 1)
- $size Selects documents if the array field is a specified size.
- $inc Increments the value of the field by the specified amount.
$inc("sold" -> 1, "stock" -> -1)
- $mul Multiplies the value of the field by the specified amount.
$rename("color" -> "colour", "realize" -> "realise")
- $setOnInsert Sets the value of a field upon document creation during an upsert. Has no effect on update operations that modify existing documents.
$setOnInsert("defaultQty" -> 500, "inStock" -> true) ++ $set("item" -> "apple")
- $set Sets the value of a field in a document.
$set("name" -> "foo", "surname" -> "bar", "age" -> 32)
- $unset Removes the specified field from a document.
$unset("name", "surname", "age")
- $min Only updates the field if the specified value is less than the existing field value.
- $max Only updates the field if the specified value is greater than the existing field value.
- $currentDate Sets the value of a field to current date, either as a Date or a Timestamp.
$currentDate("lastModified" -> true, "lastModifiedTS" -> "timestamp")
- $addToSet Adds elements to an array only if they do not already exist in the set.
$addToSet("sizes" -> "L", "colours" -> "Blue")
- $pop Removes the first or last item of an array.
$pop("scores" -> -1)
$pop("scores" -> 1)
- $pull Removes all array elements that match a specified query.
$pull("flags", "msr")
$pull("votes" $gte 6)
- $push Adds an item to an array.