Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Created December 27, 2019 11:24
Show Gist options
  • Select an option

  • Save ereshzealous/5019fdb818adaf2600d214003c89184b to your computer and use it in GitHub Desktop.

Select an option

Save ereshzealous/5019fdb818adaf2600d214003c89184b to your computer and use it in GitHub Desktop.
public Mono<Author> saveAuthor(Author author) {
if (StringUtils.isNotBlank(author.getId())) {
return authorRepository.findByIdAndDeleteIsFalse(author.getId())
.switchIfEmpty(Mono.error(new Exception("No Author found with Id: " + author.getId())))
.doOnSuccess(author1 -> {
author1 = updateAuthor(author, author1);
authorRepository.save(author1)
.subscribe();
});
}
return authorRepository.save(author);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment