How to get the last N records in mongodb?
Asked 07 September, 2021
Viewed 1.8K times
  • 51
Votes

I can't find anywhere it has been documented this. By default, the find() operation will get the records from beginning. How can I get the last N records in mongodb?

Edit: also I want the returned result ordered from less recent to most recent, not the reverse.

15 Answer