Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

MongoDB Aggregation $limit


Aggregation $limit

This aggregation stage limits the number of documents passed to the next stage.

Example

In this example, we are using the "sample_mflix" database loaded from our sample data in the Intro to Aggregations section.

db.movies.aggregate([ { $limit: 1 } ])
Try it Yourself »

This will return the 1 movie from the collection.