Before diving into the specifics, it's important to lay some groundwork. The first question which comes to mind is, What is aggregation? That question would be logically followed by, Why use it?
An overview of aggregation
What is aggregation?
The main purpose of aggregation operations is to refine query results by grouping together field values from multiple documents, and then performing one or more transformations. Aggregation in MongoDB can be as simple as presenting the results of a query into a set of one or more fields, or as complex as performing a multistage query, breaking the output into buckets, and performing operations on each result set. A more advanced usage would be to manipulate complex fields within...