$group

noun

say it: “DOL-er GROOP” /ˈdɑlər ˈɡrup/

A MongoDB aggregation stage that sorts documents into groups by a key and works out values for each group, such as totals or averages.

What does $group do?

$group combines documents that share a key and computes values per group with accumulators like $sum, $avg, $max and $push.

In a sentence

  • “$group with _id "$category" gave one row of sales per category.”
  • “Each output field of $group uses an accumulator such as $sum.”

Level: Journeyman · More MongoDB terms at this level

Updated