We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
var ArticleSchema = new mongoose.Schema({ title: String, text: String, commentsCount: Number })
Without mongoose-paginator query would look something like this:
mongoose-paginator
Article .find() .sort('-commentsCount') .limit(10) .skip(5) .exec()
How can I do it with mongoose-paginator?
The text was updated successfully, but these errors were encountered:
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
Sorry, something went wrong.
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); }
No branches or pull requests
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
?The text was updated successfully, but these errors were encountered: