Mongoose save() not updating value in an array in database document Mongoose save() not updating value in an array in database document mongoose mongoose

Mongoose save() not updating value in an array in database document


Maybe notify mongooose the dataset has changed like this :

doc.markModified('pathToYourAttribute'

From the docs http://mongoosejs.com/docs/schematypes.html

person.anything = { x: [3, 4, { y: "changed" }] }; person.markModified('anything');

Hope it helps!


Refer to this issue. One way to solve this would be not to update your array via the classic array Index method. So do this

doc.array.set(index, value);

Instead of

doc.array[index] = value;

also view the FAQ and doc for more details.


I replaced the save method with this statement:

Client_data.Unit.updateOne({_id: unit._id},unit);