For Model password encrypting

PHOTO EMBED

Sat Aug 22 2020 23:06:10 GMT+0000 (Coordinated Universal Time)

Saved by @brainyworld #nodejs #javascript

userSchema.pre('save', async function(next){
    if (!this.isModified('password')) return next()
    this.password = await bcrypt.hash(this.password, 8)

    next()
})
content_copyCOPY