I am little familiar with sails and mongoDB, Here i want to know how to sort the data while selecting from collection in DESC order.
Here i enclosed my controller function:
listall : function(req, res){
var userId = req.session.passport.user;
User.find().sort( { '_id': -1 } ).where({
id: userId
}).exec(function(err, data) {
Listing.find().where({
userid : userId
} ).exec(function(err, listdata){
console.log(listdata);
res.view('dashboard/listing', {
'userdata': data,
'userlisting' : listdata
});
});
});
Here my sorting is not done, it fetch the rocord in ASC order. Please guide me where i am doing mistake.
Thanks & Regards