Thursday, 8 June 2017

Encrypt a password field if changed with findOneAndUpdate middleware

I'm confused. Mongoose allows us to use methods update, findOneAndUpdate... etc however when passing through a middleware like pre('findOneAndUpdate') we only have access to the query. For example, the isModified method isn't available.

How am I supposed to encrypt a password field if changed and edit a timestamp in the model if anything else changed?



via Apyn AOM

No comments:

Post a Comment