Aggregation operators can be used to create expressions in the aggregation pipeline. The operators work like functions. They typically take either a single argument like this:
{[operator]: [argument]}
Or they take an array of arguments like this:
{[operator]: [[argument1], [argument2] ...]}
Aggregaton Operators Types
Type | Description |
---|---|
Boolean operators evaluate their expression and return a boolean result. | |
Comparison operators compare two arguments and return a boolean result or a number. | |
Arithmetic operators perform calculations on numbers and dates | |
String operators perform operations on string arguments. | |
Array operators perform operations on array arguments. | |
Set operators work on arrays but treats them as sets, ignoring duplicate entries and order and return a set as a result. | |
Literal operators return a value or expression without parsing or evaluating the expression. | |
Date operators perform operations on date arguments. | |
Conditional operators evaluate expressions and return a value depending on the result of the condition. | |
Accumulator operators take a single expression as input and evaluate that expression once for each document in the result set. |