Now i’ll give you a small commands for show you the limited records fetch from collection and sorting for collection data.
Record Limits
syntax: limit()
> db.collection.find().limit(NUMBER)
> db.student.find().limit(3) <——– It’s showing 3 records from collections
Record Sorting
syntax: sort()
> db.collection.find().sort({KEY:1})
> db.student.find().sort({KEY:1}) <—- Key:1 showing the data in Ascending order and if you mention -1 showing data in Descending order
No comments:
Post a Comment