有什么办法可以在Spring Webflux中实现分页和Spring数据响应 [英] Is there any way to implement pagination in spring webflux and spring data reactive
问题描述
我试图理解spring 5的反应式部分.我创建了一个简单的rest端点,用于使用spring web-flux
和spring数据反应式(mongo)查找所有实体,但是看不到如何实现分页. /p>
这是我在Kotlin中的简单示例:
@GetMapping("/posts/")
fun getAllPosts() = postRepository.findAll()
这是否意味着反应性端点不需要分页?是否有某种方法可以使用此堆栈从服务器端实现分页?
Spring Data中的反应式支持不提供Page
返回类型的方法.仍然在方法签名中支持Pageable
参数,该方法签名将limit
和offset
传递给驱动程序,并因此传递给驱动程序本身,并返回一个Flux<T>
并发出请求的范围.
Flux<Person> findByFirstname(String firstname, Pageable pageable);
有关更多信息,请查看当前的春季数据示例.
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?
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.
这篇关于有什么办法可以在Spring Webflux中实现分页和Spring数据响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!