From the course: MongoDB Aggregation Pipeline: Advanced Data Analysis and Manipulation
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Transforming data with aggregations - MongoDB Tutorial
From the course: MongoDB Aggregation Pipeline: Advanced Data Analysis and Manipulation
Transforming data with aggregations
- [Instructor] In the previous video, we wrote our first aggregation that filtered, sorted, and limited the number of documents in our collection. While a good introduction to the aggregation pipeline, these commands can be done without using the aggregation framework, by using the built-in find, limit and sort methods. In this video, we'll do something that you can only accomplish with the aggregation framework. In this video, we are going to write an aggregation that uses a dollar sign group stage. The dollar sign group stage separates documents into groups according to a group key. The output is one document for each unique group key. Now, let's open up MongoDB Compass and go into our orders collection and open up the Aggregations tab. From the dropdown menu, select the dollar sign group stage. And what we want to accomplish with the dollar sign group stage is to answer three questions about each of our customers.…