I am trying to learn spring webflux. In ReactiveMongoRepository, I am trying to check if category already exists. If it already exists then return that object otherwise save and return new saved object. Something like following.
public Mono<Category> save(Category category) {
final Mono<Category> byId = repository.findById(category.getId());
final Category block = byId.block();
if (block == null) {
return repository.save(new Category(category.getName()));
} else {
return byId;
}
}
How can I do this without using block()?
switchIfEmtpyinstead ofblock.