sort by date mongoose code example
Example: I use time stamp in mongoose sort by date
Article.find({}).sort('-date').exec(function(err, docs) { ... });Article.find({}).sort({date: -1}).exec(function(err, docs) { ... });Article.find({}).sort({date: 'desc'}).exec(function(err, docs) { ... });Article.find({}).sort({date: 'descending'}).exec(function(err, docs) { ... });Article.find({}).sort([['date', -1]]).exec(function(err, docs) { ... });Article.find({}, null, {sort: '-date'}, function(err, docs) { ... });Article.find({}, null, {sort: {date: -1}}, function(err, docs) { ... });With multiple sort fieldsArticle.find({}).sort({fieldA: 1, fieldB: 1}).exec(function(err, docs){...})