Overview
Last updated
Last updated
Aggregation framework in MongoDB is a powerful feature that allows you to build complex queries that you normally cannot build with the common operators and functions. The framework achieves this by putting your documents into a multi-stage pipeline that transforms the documents in the desired result.
The pipeline consists of a series of stages where each stage receives the output of the previous stage. The section contains samples for the following stages:
Stage
Description
Project
Adds new fields or removes existing ones
Match
Filters the documents
Group
Groups documents by an identifier expression providing accumulator results
Unwind
Deconstructs an array field
Pagination (limit, skip)
Skips the first n documents and limits the total results
Bucket
Produces a distribution among documents based on a specified expression and specified boundaries