I have a simple CRUD controller. When updating I want merge the updated model with the model that has to be updated, this is what I have at the moment:
@PutMapping("{id}")
public Mono<Map> update(@PathVariable UUID id, @RequestBody Server updatedServer) {
Mono<Server> server = this.serverRepository.findById(id);
// Update the server here.
// server.setName(updatedServer.getName());
// server.setHost(updatedServer.getHost());
server.flatMap(this.serverRepository::save).subscribe();
return Mono.just(Collections.singletonMap("success", true));
}
How can I edit the server variable before the save? When subscribing on the Mono it will be executed after the save.
I know this is a pretty simple question, but I just can't find a way to do it.