Mongoose update embedded document does not work

Greeting all,

I defined a deeply embedded mongoose model "Person", which contains a field "Contact", and "Contact" has an array of "Address" for this person's work, home, delivery etc addresses.

When I wanted to update an address, and use the model's "save" function, the change wasn't reflected in the 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 that the field City has been updated to new value, but the mongodb's value stays the same.

Could you please help me with this issue?

Thanks! Gary

The issue was resolved by using markModified:

person.markModified('Contact.Address');
person.save()

Still not sure when I need to use markModified, because in most other cases the change was reflected in mongodb without using it.