I'm trying to adapt the postgresql repository deleteById
method which return void
to return Mono<Void>
the repository is a service that I autowired, I use it like this
repository.deleteById(id)
with String id as the argument
If you want to use reactive stack, then you should use spring-data-r2dbc , which provides ReactiveCrudRepository
and method Mono<Void> deleteById(ID id)
.
If for some reason you need to use a synchronous method, then you could wrap deleteById
call using Mono.fromRunnable
Mono.fromRunnable(() -> repository.deleteById(someId))
However, this should be avoided, because then you get no benefits of using reactive stack.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.