Aggregation Operators

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

TypeDescription
Boolean OperatorsBoolean operators evaluate their expression and return a boolean result.
Comparison OperatorsComparison operators compare two arguments and return a boolean result or a number.
Arithmetic OperatorsArithmetic operators perform calculations on numbers and dates
String OperatorsString operators perform operations on string arguments.
Array OperatorsArray operators perform operations on array arguments.
Set OperatorsSet operators work on arrays but treats them as sets, ignoring duplicate entries and order and return a set as a result.
Literal OperatorsLiteral operators return a value or expression without parsing or evaluating the expression.
Date OperatorsDate operators perform operations on date arguments.
Conditional OperatorsConditional operators evaluate expressions and return a value depending on the result of the condition.
Accumulator OperatorsAccumulator operators take a single expression as input and evaluate that expression once for each document in the result set.