The aggregation pipeline's $group stage buckets documents by city ($city references the field) and $sum: 1 counts each bucket. This is MongoDB's GROUP BY. Related: find() for plain queries.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.