Issue
I'm trying to understand reactive part of spring 5. I have created simple rest endpoint for finding all entities using spring web-flux
and spring data reactive (mongo) but don't see any way how to implement pagination.
Here is my simple example in Kotlin:
@GetMapping("/posts/")
fun getAllPosts() = postRepository.findAll()
Does it mean that reactive endpoint does not require pagination? Is some way to implement pagination from server side using this stack?
Solution
The reactive support in Spring Data does not provide means of a Page
return type. Still, the Pageable
parameter is supported in method signatures passing on limit
and offset
to the drivers and therefore the store itself, returning a Flux<T>
that emits the range requested.
Flux<Person> findByFirstname(String firstname, Pageable pageable);
For more information please have a look at the current Reference Documentation for 2.0.RC2 and the Spring Data Examples.
Answered By - Christoph Strobl
Answer Checked By - Cary Denson (JavaFixing Admin)