Another group of operators, referred to as accumulators, are used to collect results such as producing totals. These operators are generally tied to specific aggregation pipeline stages, including $addFields, $group, and $project. Here is a brief summary of the more important accumulators associated with the $group, $addFields, and $project pipeline stages:
| Operator | Notes |
| $sum | Produces a sum of one of the fields in the group. The sum can also be produced from an expression, which might involve additional fields and/or operators. Any non-numeric values are ignored. |
| $function | Allows you to define a JavaScript function, the results of which are made available to this pipeline stage. Only available as of MongoDB 4.4, this expression operation completely eliminates the need for Map-Reduce. |
| $accumulator | Introduced in MongoDB 4.4, this operator lets you include a JavaScript function to produce results, making this an extremely valuable general-purpose... |