Return only a fixed number of documents.
Section: Projection, sort, and page
Limit result size
javascript
javascript
db.orders.find().sort({ created_at: -1 }).limit(20)Explanation
Limit is a basic building block for API endpoints and dashboards.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Projection, sort, and page