Open kulakowka opened 7 years ago
Hi @kulakowka,
I believe you want todo something like this
Article.paginate({ sort: 'desc' }, 'commentsCount')
.limit(10)
.execPagination(function(err, results) {
});
Please let me know if this works for you
Thank you @jonlil. I can do it tonight. At first glance, yes - that's what I need. I will inform you of the results.
Yes - that's what I need! Many thanks @jonlil.
I think it would be good to add this example in the documentation.
Hi, here is another example:
async getFromProfession(req, res) {
const { page = 1 } = req.query;
const jurymans = await Juryman.paginate(
{ profession: req.params.profession },
{
page,
limit: 10,
sort: {
createdAt: -1 //Sort by Date Added DESC
}
}
);
return res.json(jurymans);
}
Dear @jonlil.
Could you help me understand? I would like to get a list of articles sorted by number of comments.
Let my scheme looks like this:
Without
mongoose-paginator
query would look something like this:How can I do it with
mongoose-paginator
?