Comparison JSON operators

A number of different comparison operators are supported.

Table 1. Comparison JSON operators
Operator Description Example
  Returns any documents that match the specified value. It is also referred to as the equality comparator operator. {"name":"Joe"}
$ne Returns any documents that do not match the specified value. It is also referred to as the inequality comparator operator. {"age":{"$ne":3}}
$in Returns any documents that match any of the specified values in the set. It is also referred to as the in comparison operator. Use only one data type in the specified values. {"age":{"$in":[1,2,3,4,5]}}
$nin Returns any documents that do not match any of the specified values in the set. It is also referred to as the not in comparison operator. {"age":{"$nin":[1,2,3,4]}}
$lt Returns any documents that have a value that is less than the specified value in the set. It is also referred to as the less than comparison operator. {"age":{"$lt":3}}
$lte Returns any documents that have a value that is less than or equal to the specified value in the set. It is also referred to as the less than or equals comparison operator. {"age":{"$lte":3}}
$gt Returns any documents that have a value that is greater than the specified value in the set. It is also referred to as the greater than comparison operator. {"age":{"$gt":3}}
$gte Returns any documents that have a value that is greater than or equal to the specified value in the set. It is also referred to as the greater than or equals comparison operator. {"age":{"$gte":3}}
$regex Returns any documents that have an expression that matches a pattern of strings in the set. It is also referred to as the regular expression predicate. {"name":{"$regex":/^a.*\/}}