From the course: MongoDB Aggregation Pipeline: Advanced Data Analysis and Manipulation

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

$match, $sort, $limit

$match, $sort, $limit

- [Instructor] All right, let's get into writing some MongoDB aggregations. For all of the aggregations we write, I'm going to show you two ways to do it. First, we'll write our aggregation using MongoDB Compass. This will allow us to build our aggregation using a gooey and we'll be able to easily see how our data is transformed at each stage. Second, we're going to write the same aggregation using a MongoDB driver. And for this course, we'll use the Node.js driver, but the concepts will translate to any other language or framework. The first aggregation that we're going to write is a three-stage pipeline consisting of a $match stage, $source stage, and a $limit stage. The $match stage will filter our documents and return a subset of the entire collection. The $sort stage will order our working data set in the sending order. And finally, the $limit stage will further limit the number of documents returned. We will be…

Contents