Unfortunately I don't have a record I can test this on, but I can't find any information on this anywhere.
Say I have a document like this:
{
email: {
type: 'Gmail',
data: {//freeform data},
}
}
I want to update doc.email.data
. I need to use markModified()
or else the data won't save correctly.
Do I mark modified like this?
doc.email.data = newData;
doc.markModified('email.data');
doc.save();
Or do I just do markModified('email')
and Mongoose will work out the rest?
您需要提供修改后的对象字段的完整路径,因此它应该是:
doc.markModified('email.data');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.