Sorting:
sording in ascending and descending order for documents in collection is possible. sort() method is used for this. it takes one parameter:
1 -- ascending
-1 -- descending
command:
db.collectionname.find().sort({"key":1})
db.collectionname.find().sort({"key":-1})
the default is ascending order
the default is ascending order
No comments:
Post a Comment