how to return differnt things when insert
Storm-Born opened this issue · 1 comments
how to writing the code which can return diffenent value such as true or false base on the operation result when using mongodb react api to insert an object into database.
the code below may describe my wish, but it was not true, some methods are not exist.
mongo.insert(data).Onsuccess(return true).onError(return false).
Project Reactor provides a pretty extensive guide explaining which operator to use. You can achieve what you're looking for through the following operators:
.thenReturn(true).onErrorResume(e -> Mono.just(false))
Taking a step back, the way you're describing the issue indicates that you're trying to apply imperative patterns using reactive programming. You should familiarize yourself with Reactive Streams and the signal types (completion, error signals) to use the intrinsics of the programming model for chaining operations and handling errors.