$avg
Reference group: Accumulators and ranking
What it does
Computes arithmetic mean.
Syntax
{$avg: expression}
Use case
Average prices, scores, or durations.
$avg: practical example
{ $group: { _id: "$category", averagePrice: { $avg: "$price" } } }💡 Explanation
Computes arithmetic mean.
When to use it
Average prices, scores, or durations.
Key Takeaways
- Computes arithmetic mean.
- Typical use: Average prices, scores, or durations.