Skip to main content

2 docs tagged with "group"

View All Tags

$group

The $group stage in MongoDB's aggregation pipeline is used to group documents by some specified expression and output a document for each distinct grouping. The grouped documents can then be processed using various accumulator operators to perform calculations such as summing, averaging, or finding the minimum and maximum values.

$project

The $project stage in MongoDB's aggregation pipeline is used to selectively pass along specified fields to the next stage of the pipeline. This stage can either add new fields, remove existing fields, or reshape and transform the structure of the documents. It's similar to the SELECT statement in SQL but with more capabilities, such as renaming fields, computing new values, and creating nested structures.