MongoDB Aggregation
MongoDB Aggregation
transform and combine data from multiple documents to generate new information not available in any single document.
you can think of the aggregation framework as MongoDB’s equivalent to the SQL GROUP BY clause.

PipeLine

- $project —Specify fields to be placed in the output document (projected).
- $match —Select documents to be processed, similar to find().
- $limit —Limit the number of documents to be passed to the next step.
- $skip —Skip a specified number of documents.
- $unwind —Expand an array, generating one output document for each array entry.
- $group —Group documents by a specified key.
- $sort —Sort documents.
- $geoNear —Select documents near a geospatial location.
- $out —Write the results of the pipeline to a collection (new in v2.6).
- $redact —Control access to certain data (new in v2.6).

pseudo-join

out + project
With the $out operator, you can automatically save the output from a pipeline into a collection
The $project operator allows you to filter which fields will be passed to the next stage of the pipeline.
unwind
This operator allows you to expand an array, generating one output document for every input document array entry.