Search code examples
paginationibm-cloudibm-mobilefirstcloudant

Cloudant DB api supports pagination?


I have an app already using cloudant.synch.query.IndexManager to query the db. But I need pagination. I can see Cloudant supports it by using bookmark, but I can only find doc about using HTTP Post to url Path: /db/_find. the methods in IndexManager don't have bookmark. Is there an cloudant api I can use, instead of doing the http post?

My app is Android and iOS app that uses IBM Bluemix MobileFirst service as the back end. And I'm using bms_samples_android_bluelist (https://github.com/ibm-bluemix-mobile-services/bms-samples-android-bluelist)as an example.


Solution

  • Use Skip and Limit for paging.

    I got this from Cloudand Synch doc https://github.com/cloudant/sync-android/blob/master/doc/query.md

    Skip and limit

    Skip and limit allow retrieving subsets of the results. Amongst other things, this is useful in pagination.

    skip skips over a number of results from the result set. limit defines the maximum number of results to return for the query. To display the twenty-first to thirtieth results:

    QueryResult result = im.find(query, 20, 10, fields, null); To disable:

    skip, pass 0 as the skip argument. limit, pass 0 as the limit argument.