π $limit
If we return too many documents but we're interested in only a few, we can limit the number of documents returned using $limit
.
- Atlas UI
- MongoDB Shell
[
{ $limit: 1 }
]
db.books.aggregate([
{ $limit: 1 }
])
This returns just one document.
π Return just 7 books
.
Answer
- Atlas UI
- MongoDB Shell
[
{ $limit: 7 }
]
db.books.aggregate([
{ $limit: 7 }
])