Measure product demand
Grouping after `$unwind` changes the grain from orders to products. Accumulators can then measure both physical demand and money from the same line-item stream.
Using completed orders, return `productId`, total `units`, and `revenue` for every product. Sort by revenue descending, then product ID ascending.
Expected result: One clean demand summary per sold product.
Example pipeline syntax
[
{ $match: { status: "completed" } },
{ $unwind: "$items" }
]