- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $cmp (aggregation)
$cmp (aggregation)¶
On this page
Definition¶
-
$cmp¶ Compares two values and returns:
-1if the first value is less than the second.1if the first value is greater than the second.0if the two values are equivalent.
The
$cmpcompares both value and type, using the specified BSON comparison order for values of different types.$cmphas the following syntax:For more information on expressions, see Expressions.