Learn › Advanced aggregation
Facets, dates and full problems
$facet for dashboards and paging, date grouping, and one end-to-end interview problem.
By the end: Answer several questions in one round trip, and finish a real coding-round task.
Lessons
- $facet: several pipelines at once
MongoDB $facet runs several independent pipelines over the same input, returning all their results in one document.
- Paging and total count in one query
Get a page of MongoDB results and the total count in one query, using $facet with $skip/$limit and $count.
- Grouping by date
Group MongoDB documents by date: $year, $month, $dayOfMonth and $dateToString for readable month labels.
- A full coding-round problem, worked
A full MongoDB aggregation interview problem worked end to end: top customers by spend, joined to their user records.