microsoft / spring-data-cosmosdb

Access data with Azure Cosmos DB
MIT License
94 stars 64 forks source link

Springboot CosmosRepository with continuation token #558

Open rannoune opened 3 years ago

rannoune commented 3 years ago

We are building an API with pagination and continuation token, so that our consumer can use the continuation token for the next call. We are using CosmosRepository with spring. This is the dependency we are using:

<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>azure-spring-boot-starter-cosmos</artifactId>
    <version>3.1.0</version>
</dependency>

CosmosRepository code: com.azure.core.http.rest.Page findAllBy....(..., CosmosPageRequest request)

The above code is throwing an exception: com.azure.spring.data.cosmos.exception.CosmosAccessException: Too many results - return type interface com.azure.core.http.rest.Page is not of type Iterable but find returned 2 results] with root cause

If we use the spring Page in the return, then we won't be able to get the continuationToken

Can you please tell us how to implement Pagination with CosmosRepository and continuation token?

yiliuTo commented 3 years ago

Hi, @kushagraThapar and @mbhaskar could you help to take a look of this issue? Thanks~