MongoDB query compiled from plain English against the ecommerce sample schema, then verified by running it.
{
"type": "aggregation",
"collection": "orders",
"pipeline": [
{},
{},
{},
{},
{},
{},
{}
]
}
$unwind — flattens $productIds into one document per element.$lookup — joins the products collection on productIds → _id.$unwind — flattens $product into one document per element.$group — groups by "$product.category" and aggregates orderCount.$sort — orders by orderCount.$limit — caps the result at 1 documents.$project — returns only _id, category, orderCount.$group, orderCount counts documents in each group — one output document per distinct "$product.category".Live output from running this query against the sample dataset.
| orderCount | category |
|---|---|
| 3 | electronics |
Write this in plain English instead. Mask Databases compiles the sentence above into exactly this query at build time — no AI at runtime, and you can read the output in a diff.
Try it in the playground → No signup, runs in your browser.