Skip to content

SQL Reference

AGGREGATE

db.collection.aggregate(pipeline, options)

Section titled “db.collection.aggregate(pipeline, options)”
  • pipeline: An array of aggregation stages such as $match, $group, and $sort.
  • options: Optional settings such as allowDiskUse and maxTimeMS.
db.orders.aggregate([
{ $match: { status: "shipped" } },
{ $group: { _id: "$customerId", total: { $sum: "$amount" } } }
])