Skip to content
Advertisement

Update 1 or multiple specific field MongoDB using Spring boot WebFlux,Spring Data MongoDB Reactive and ReactiveMongoRepository

I’m newbie with java. I tried to implement update method for my API. I want to update some field of my data. Here is my data class:

JavaScript

My service interface:

JavaScript

And implement for services:

JavaScript

My Controller:

JavaScript

And Task Repository:

JavaScript

My data in DB:

JavaScript

My request body:

JavaScript

I expected:

JavaScript

But it responsed:

JavaScript

It update my missing value in request with null value. How can I update specific values in data?

Advertisement

Answer

The problem is here:

JavaScript

You completely ignore the fetched Task (b instance) and update the task with its own values. You probably need something like this:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement