Mongoose query to sort, skip and limit


This Content is from Stack Overflow. Question asked by Kiran S youtube channel

Here is my mongoose code which does sorting
And pagination. Here when i am removing sorting
or adding other type of sort no result is coming.
And i have 3000 documents in db

  res = await Question.find(filters)
  .sort({'_id': "-1"})
  .skip(args.skip ? parseInt(args.skip) : 0)
  .limit(args.limit ? parseInt(args.limit) : 100)

Please take a look


Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?