MongoDB Pagination – using range queries
This method of MongoDB pagination requires manually setting the _id field in your documents. It uses the min() and max() MongoDB cursor functions to implement the pagination.
We'll be learning by examples on a collection named 'companies'. Make sure there are no documents on it.
[code]
db.companies.remove()
[/code]
Make sure the _id value starts from 0 and increment ...