MongoDB query compiled from plain English against the ecommerce sample schema, then verified by running it.
{
"type": "aggregation",
"collection": "orders",
"pipeline": [
{},
{},
{},
{},
{},
{}
]
}
$sort — orders by placedAt.$group — groups by "$customerId" and aggregates order.$replaceRoot — reshapes each result into its final form.$lookup — joins the customers collection on customerId → _id.$unwind — flattens $customer into one document per element.$project — returns only customerId, productIds, totalCents, status, placedAt, customer.totalCents stores money as an integer number of cents — divide by 100 before displaying it.$unwind fans one document into many — one per joined item. The $group / $replaceRoot pair afterwards puts them back together, so you get one result per original document instead of duplicates.$group, order takes the first value in the group — one output document per distinct "$customerId".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.