title: hashed passwords are not being saved with pre save hook in mongoose
body: <p>I am using Postman to test an API that I am working on for a project.  I am sending</p>
  
  <pre><code>{
      "fullName": "Smellydog",
      "emailAddress": "SmellydogCoding@gmail.com",
      "password": "password",
      "confirmPassword": "password"
  }
  </code></pre>
  
  <p>as the request body to this API route</p>
  
  <pre><code>users.post('/', (req, res, next) =&gt; {
    let user = new Users(req.body);
    user.save((error,user) =&gt; {
      if (error) {
        return next(error);
      } else {
        res.status = 201;
        res.location('/');
        res.end();
      }
    });
  });
  </code></pre>
  
  <p>This is my Users Schema</p>
  
  <pre><code>const mongoose = require('mongoose');
  const bcrypt = require('bcrypt');
  const emailRegex = /^(([^&lt;&gt;()\[\]\\.,;:\s@"]+(\.[^&lt;&gt;()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  
  const UserSchema = new mongoose.Schema({
      fullName: {
        type: String,
        required: true,
        trim: true,
      },
      emailAddress: {
        type: String,
        required: true,
        unique: true,
        match: [emailRegex, "Please enter a valid email address"],
        trim: true
      },
      password: {
        type: String,
        required: true
      },
      confirmPassword: {
        type: String,
        required: true
      }
  });
  
  // hash password before saving to database
  UserSchema.pre('save', function(next)  {
    bcrypt.hash(this.password, 10, function(error, hash) {
      if (error) {
        return next(error);
      } else {
        this.password = hash;
        this.confirmPassword = hash;
        next();
      }
    });
  });
  
  UserSchema.pre('validate', function(next) {
    let user = this;
    if (user.password !== user.confirmPassword) {
      return next('Passwords must match');
    } else {
      next();
    }
  });
  
  const User = mongoose.model('User', UserSchema);
  module.exports = User;
  </code></pre>
  
  <p>The pre save hook is supposed to encrypt the password and then save it to the password and confirmPassword fields.  If I use Chrome debugger to set a breakpoint at the end of the pre save hook (where next() is called), and inspect this.password and this.confirmPassword, I see that they are set to the newly created hash, but when I check the database afterwards both of those fields are set to the original password string</p>
  
  <pre><code>{
      "_id": "58d835f0d026194610578c74",
      "fullName": "Smellydog",
      "emailAddress": "SmellydogCoding@gmail.com",
      "password": "password",
      "confirmPassword": "password",
      "__v": 0
    }
  </code></pre>