From the course: MongoDB Aggregation Pipeline: Advanced Data Analysis and Manipulation
Overview of the MongoDB aggregation framework - MongoDB Tutorial
From the course: MongoDB Aggregation Pipeline: Advanced Data Analysis and Manipulation
Overview of the MongoDB aggregation framework
- [Instructor] The MongoDB aggregation framework is an essential component of the MongoDB ecosystem. The aggregation framework enables developers to perform various types of data analysis, reporting and manipulation of data using the MongoDB aggregation pipeline. The aggregation pipeline is a component of the aggregation framework that makes data transformation possible through a concept that MongoDB calls pipeline stages. Writing aggregation pipeline stages is very similar to writing traditional MongoDB queries, and if you're already familiar with the MongoDB query language you'll feel right at home. In the aggregation pipeline data passes through one or many of these stages and at each stage is transformed, filtered or manipulated to produce an end result which is then returned to the developer. A simple example of the aggregation framework is the traditional three stage, $match, $sort and $limit pipeline, that filters documents in a MongoDB database collection based on a certain criteria defined in the $match stage, sorts the filter results from the $match stage in the sort stage and then finally returns a subset of the sorted data as defined in the $limit stage. We'll write this aggregation and look at it more in depth in a later video. Before we die further. Know that we'll use the terms aggregation framework, MongoDB aggregations and aggregation pipeline somewhat interchangeably throughout this course, but know that all of these terms refer to the MongoDB aggregation framework. All right, so let's talk about the need for the aggregation framework. Like other databases, MongoDB has a very powerful query language that allows you to create, read, update, and delete data. When it comes to reading or querying your data you often want more than just the raw data. You may want to answer questions about your data, like, "What is the average order value for my e-commerce store in Q2?" Or, "How can I identify customer patterns to make better recommendations?" This is where the MongoDB aggregation framework shines. SQL databases have had aggregation functions for a very long time and the MongoDB aggregation framework is similar in this regard. It was created to allow developers to write more complex queries that can execute directly on the database server rather than having to manipulate raw data at the application level. The MongoDB aggregation framework has over 35 different aggregation commands at your disposal and will learn about many of them in this course. Next, let's dive a little bit deeper into the aggregation pipeline stages.