Mongoose: mark has "not modified" on doc

Created on 29 Dec 2013  Â·  8Comments  Â·  Source: Automattic/mongoose

I've been through the entire API but still
In a pre('save') ,if one of my field is modified doc.isModified('myField')

how can we mark that field as not modified in order to remove that field in the update query. I don't want to remove the field in the db with doc.myField = undefined, just omit the save on that field.

a good way wood be doc.markNotModified('field')

any idea ?
thanks

new feature

Most helpful comment

Note that for people finding this issue, the method is actually called unmarkModified()

All 8 comments

ok i'm sorry :) this is allready there

https://github.com/LearnBoost/mongoose/pull/1167

this community is fucking awsome ^^

Ooups , reopening

doc.markNotModified() does not exist yet :)

I'll give it a try if no one has been facing that issue

go for it!

On Sunday, December 29, 2013, louis wrote:

Ooups , reopening

doc.markNotModified() does not exist yet :)

I'll give it a try if no one has been facing that issue

—
Reply to this email directly or view it on GitHubhttps://github.com/LearnBoost/mongoose/issues/1854#issuecomment-31319256
.

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann
soundcloud.com/ajhecky
github.com/aheckmann

Is this still something we want? I could go ahead and implement it @vkarpov15

@onbjerg go for it, any help would be much appreciated.

Fixed in 4.5.0.

Note that for people finding this issue, the method is actually called unmarkModified()

Thanks @adamreisnz

Was this page helpful?
0 / 5 - 0 ratings