Search code examples
reactive-programmingcouchbasespring-data-couchbase

Does Spring Data Couchbase reactive support pagination?


I have use-case to provide an api which returns list of users. As there are more than 10000 users so there is a need for pagination as well. As I am using Spring data couchbase reactive I am not able to find a way to implement pagination in a reactive way for my api.

Is it possible to achieve pagination by which api callers can control how many number of records they want and they can process?


Solution

  • You can use the standard N1QL LIMIT and OFFSET:

    @Query("#{#n1ql.selectEntity} where #{#n1ql.filter} and companyId = $1 LIMIT $2 OFFSET $3")
    Flux<Users> listUsers(String companyId, Integer limit, Integer offset);