I am interested in a pagination solution for documents stored in MongoDB. I use Salat/Casbah in order to work with this data. As far as I can tell, there is nothing readily available in as far as open source to paginate data using those two solutions. Is there a solution I'm currently overlooking in order to paginate data that I'm displaying in an HTTP API using those as my drivers?
Asked
Active
Viewed 372 times
2 Answers
2
Despite its cheesy attempts at humor, this post on MongoDB paging is pretty good and focuses on range queries and associated techniques to paginate your data. How you actually do it depends on the amount of data and the nature of your application.

Vidya
- 29,932
- 7
- 42
- 70
1
please, be careful with pagination! In MongoDB pagination very often results in iteration over entire collection. Exactly because of this casbah doesn't have good pagination solution. You can try to use filtering instead of pagination, for example when result is ordered by field relevance, selecting results where relevance > some value
There're a lot of information about how to do efficient paging in mongodb, e.g.: MongoDB - paging
-
I will read through this, and that's exactly why I made this post - to learn about to gotchyas. The other issue I have is that I need to make two queries - one for the 'subset' of data and one for the 'total count' of results. Was wondering if MongoDB has a way to do this with one query. – randombits Feb 15 '14 at 20:07
-
Not sure about the count. – vitalii Feb 15 '14 at 20:12