Pipeline Practice

Assemble an operations dashboard

A production-style `$facet` is a contract made from several independent grains. Each branch must own its transformations, ordering, and final shape without relying on another branch.

For completed orders, return one document with `regionalRevenue`, `largestOrders`, and `unitsByChannel`. Regional summaries need revenue and order count; largest orders need the top three compact order records; channel summaries need item units.

Expected result: One document containing three ordered report arrays and at least 11 stage operations across all branches.

Example pipeline syntax

[
  { $match: { status: "completed" } },
  { $facet: {
    regionalRevenue: [],
    largestOrders: [],
    unitsByChannel: []
  } }
]