How to save new / update existing mongoose nested array? Do we need different function to achieve (save new/update existing) this or do we need separate function for each task?
Dummy Model
var user = new Schema({
name : String,
cars: [{brand: String, prices:[ {color : String, value: String}] }],
}
let saveUpdate = await User.findOneAndUpdate(
{ _id: req.id },
{ $set: { cars: ---- } }
);
I have to save new car details and update car model or update price value based on color field