About
How to read these patterns
- Leading commas
- Conventions in this pack
Sample data
- On Atlas
- On local MongoDB
- What a sale looks like
How to run the examples
- mongosh
- Compass
- Node scripts
Pattern 1 — Time-bucket totals
- When this pattern fits
- When it does not fit
- Sample document (trimmed from Atlas)
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 2 — Top-N per category
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 3 — Running totals / cumulative series
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 4 — Period-over-period
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 5 — Null-safe metrics
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 6 — Multi-collection report via $lookup
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 7 — Faceted dashboard payload
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 8 — Histogram / distribution
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 9 — Active vs churned in a window
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline
- Expected output shape
- Watch out
- Variations
Pattern 10 — Pagination-friendly report pages
- When this pattern fits
- When it does not fit
- Sample data
- Pipeline — page and count
- Keyset variation (preferred for deep pages)
- Expected output shape (facet form)
- Watch out
- Variations