I am using Waterline ORM for sails.js. limit
and sort
are not working when you use groupby
, but are working fine when you dont do any grouping .
For example
Model.find({
groupBy:['term'],
sum:['count'],
limit:20,
sort :'count DESC'}).exec(function(error,response){
if(error) res.json(error);
res.json(response);
});
Use
Model.find()
.groupBy('term')
.sum('count')
.limit(20)
.sort({count: 'desc'})
.exec(function (err, data){
//Your code here..
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With