aqui ele ensina com SQL, to querendo com MongoDB.

https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/