thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

MongoDB Aggregation Pipeline

A MongoDB framework that processes documents through ordered stages such as $match, $group, $project, $sort, $lookup and $unwind.

Definition

Each stage transforms the stream of documents. $match early lets indexes be used and reduces work, $lookup performs a left outer join to another collection, and $unwind expands arrays into one document per element.

Example

db.orders.aggregate([{ $match: {status: 'A'} }, { $group: { _id: '$cust', total: { $sum: '$amount' } } }])

Exam tip

Place $match and $sort early so indexes can be used; $lookup is MongoDB's join.

Related terms