Answers for "how to update a value in an array in mongoose"

1

updating an array of object in mongoose

Person.update(
   {
     _id: 5,
     grades: { $elemMatch: { grade: { $lte: 90 }, mean: { $gt: 80 } } }
   },
   { $set: { "grades.$.std" : 6 } }
)
Posted by: Guest on August-23-2020
0

mongoose wont update value in array

//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');
Posted by: Guest on April-01-2021

Code answers related to "how to update a value in an array in mongoose"

Code answers related to "Javascript"

Browse Popular Code Answers by Language