I want to modify a json object stored in field "additionalCharges" for Vehicles in Database. The main goal is to update the specific without replacing the whole json object. This should happen when I make an assignment such as transport assignment. the Schema of additionalCharges is:
additionalCharges:{
transport: 300,
service: 100,
...
}
The action for transportAssignment is as follows:
assignment = await TransportationAssignment.updateOne({ id }).set({
...inputs,
});
// update price of vehicle.additionalCharges.transport
await Vehicle.updateOne({ id: assignment.vehicle }).set({
"additionalCharges.transport": assignment.shipmentPrice,
});
However this does not work. How can i achieve this?