Created
July 15, 2015 07:26
-
-
Save gistfrojd/6b12be2d54c7ca7cb31e to your computer and use it in GitHub Desktop.
How to perform sorting in mongoose (from http://stackoverflow.com/a/15081087)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Room.find({}).sort('-date').exec(function(err, docs) { ... }); | |
Room.find({}).sort({date: -1}).exec(function(err, docs) { ... }); | |
Room.find({}).sort({date: 'desc'}).exec(function(err, docs) { ... }); | |
Room.find({}).sort({date: 'descending'}).exec(function(err, docs) { ... }); | |
Room.find({}, null, {sort: {date: -1}}, function(err, docs) { ... }); | |
Room.find({}, null, {sort: [['date', -1]]}, function(err, docs) { ... }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment