Pipeline Practice

Roll up a monthly revenue series

Time-series pipelines need real date values and explicit interval boundaries. Convert text once, truncate every event to the same calendar unit, then group on that normalized timestamp.

For completed orders, calculate monthly revenue and order count. Return `month`, `revenue`, and `orderCount` in chronological order.

Expected result: Two month records beginning at 2026-01-01 and 2026-02-01 UTC.

Example pipeline syntax

[
  { $match: { status: "completed" } },
  { $group: { _id: "$placedAt", revenue: { $sum: "$total" } } }
]