node.js - Mongoose update embedded document does not work -
greeting all,
i defined embedded mongoose model "person", contains field "contact", , "contact" has array of "address" person's work, home, delivery etc addresses.
when wanted update address, , utilize model's "save" function, alter wasn't reflected in database.
console.log(person.contact.address[i].city = 'chicago'); person.save(function (err) { if (!err) { console.log(person.contact.address[i].city); the console.log indicates field city has been updated new value, mongodb's value stays same.
could please help me issue?
thanks! gary
the issue resolved using markmodified:
person.markmodified('contact.address'); person.save() still not sure when need utilize markmodified, because in other cases alter reflected in mongodb without using it.
node.js mongoose
No comments:
Post a Comment