Tsallaka zuwa abun ciki
Justice Tech School

$group

Group and total values.

Example
db.sales.aggregate([
  { $group: { _id: "$region", n: { $sum: 1 }, avg: { $avg: "$amount" } } }
])

Exercise

Count each.

n: { : 1 }

Quiz Test

What does _id hold in $group?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.