Mongodb 未将哈希密码持久化到Mongo DB数据库

Mongodb 未将哈希密码持久化到Mongo DB数据库,mongodb,mongoose,bcrypt,Mongodb,Mongoose,Bcrypt,因此,在保存用户之前,我想使用bcrypt散列密码: UserSchema.pre('save', function(next) { const myPlaintextPassword = this.password; const saltRounds = 1; bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) { if(err) { r

因此,在保存用户之前,我想使用bcrypt散列密码:

UserSchema.pre('save', function(next) {

      const myPlaintextPassword = this.password;
      const saltRounds = 1;
      bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
         if(err) {
            return next(err);
         }
         this.password = hash;
      });

      next();
 });
那么这里出了什么问题?为什么密码没有被持久化