$avg
Calculates the arithmetic mean of the supplied numeric values.
Syntax
{ "$avg": <arrayExpression> }
Example
Input
{ "scores": [90, 85, 95] }
Stage
{ "$project": { "averageScore": { "$avg": "$scores" } } }
Output
{ "averageScore": 90 }
Calculates the arithmetic mean of the supplied numeric values.
{ "$avg": <arrayExpression> }
{ "scores": [90, 85, 95] }
{ "$project": { "averageScore": { "$avg": "$scores" } } }
{ "averageScore": 90 }