password encrpytion before entering database: pre("save") function

a simple documentation on hashing password before saving into db A user schema model has been defined, using mongoose, it looks something like this: const userSchema = new mongoose . Schema ({ email : { type : String , required : true , unique : true , minlength : 4 , lowercase : true , }, username : { type : String , required : true , unique : true , minlength : 4 , trim : true , }, password : {…