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

Type

Description

Boolean Operators

Boolean operators evaluate their expression and return a boolean result.

Comparison Operators

Comparison operators compare two arguments and return a boolean result or a number.

Arithmetic Operators

Arithmetic operators perform calculations on numbers and dates

String Operators

String operators perform operations on string arguments.

Array Operators

Array operators perform operations on array arguments.

Set Operators

Set operators work on arrays but treats them as sets, ignoring duplicate entries and order and return a set as a result.

Literal Operators

Literal operators return a value or expression without parsing or evaluating the expression.

Date Operators

Date operators perform operations on date arguments.

Conditional Operators

Conditional operators evaluate expressions and return a value depending on the result of the condition.

Accumulator Operators

Accumulator operators take a single expression as input and evaluate that expression once for each document in the result set.