It’s a sequence of stages (`$match`, `$group`, `$project`, ...) that transforms documents and can compute aggregates. Use it for reporting, grouping, filtering, and shaping data on the server side.
db.orders.aggregate([
{ $match: { status: "PAID" } },
{ $group: { _id: "$customerId", total: { $sum: "$amount" } } }
])