Query Operators#

Comparison#

$eq

Matches values that are equal to a specified value.

$ne

Matches all values that are not 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.

$lt, $<

Matches values that are less than a specified value.

$lte, $<=

Matches values that are less than or equal to a specified value.

$in

Matches any of the values specified in an array.

$nin

Matches none of the values specified in an array.

Logical#

$and, $all

Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.

$or, $any

Joins query clauses with a logical OR returns all documents that match the conditions of either clause.

$not

Inverts the effect of a query expression and returns documents that do not match the query expression.

Element#

$exists

Matches documents that have the specified field.

$type, $is

Selects documents if a field is of the specified type.

Array#

$size, $length

Selects documents if the array field is a specified size.

$elemMatch

Selects documents if any element in the array field matches the specified query.

$contains

Matches arrays that contain the specified element.

$notcontains

Matches arrays that don’t contain the specified element.

Evaluation#

$regex

Selects documents where values match a specified regular expression.

$where, $func, $f

Matches documents that satisfy a Python filter function.