title: Mongoose Pre-Save Hook is Firing, but Not Saving Additional Field (NOT using model.update)
body: <p>I am attempting to implement a counter in my schema to grab the next issue number.    I have implemented it as a hook pre-save hook in Mongoose, and everything looks fine... with the exception the actual 'number' field does not update.   I can easily tell the hook is firing off by what gets logged to the console, even the field seems to get assigned.   But alas, no matter what I try, the 'number' field does not end up in the results.</p>
  
  <p>I have seen a couple issues related to Mongoose hooks, but they all seem to be related to findOneAndUpdate or the like, which I am not using.</p>
  
  <p><strong>Here is my full model with the hooks at the bottom:</strong></p>
  
  <pre><code>var mongoose = require('mongoose');
  var Schema = mongoose.Schema;
  var Project = require('./projects.js');
  
  var IssueSchema = new Schema({
      title: {type: String, required: true, trim: true,  index: true},
      number: {type: Number},
      description: {type: String, required: true},
      vote_up: {type: Number, default: 0},
      vote_down: {type: Number, default: 0},
      comments: [new Schema({
        _id: {type: Schema.ObjectId, ref: 'users'},
        description : {type: String},
        likes: {type: Number},
        date: {type: Date}
      })],
      attachments: [],
      fields: [new Schema({
        _id: {type: Schema.ObjectId, ref: 'fields'},
        value : {type: String}
      })],
      project: {type: Schema.ObjectId, required: true, index: true, ref: 'projects'},
      tags: {type: [Schema.ObjectId], required: false, default: ['56a2a0b1ea805d403f6d014b']},
      isResolved: {type: Boolean, default: false},
      created_by: {type: Schema.ObjectId, required: true, ref: 'users'},
      updated_by: {type: Schema.ObjectId, required: false, ref: 'users'},
      created_at: {type: Date, default: Date.now},
      updated_at: {type: Date, default: Date.now}
  });
  
  IssueSchema.pre('save', function(next){
      var now = new Date();
      this.updated_at = now;
      if(!this.created_at) {
          this.created_at = now;
      }
      next();
  })
  .pre('save', function(next) {
    Project.findOne({_id: this.project}).select('numberSeq').exec(function(err, doc) {
      if (err) {
        console.log(err);
      }
      console.log('pre-save hook firing');
        this.number = doc.numberSeq;
        console.log(this.number);
        next();
      });
  })
  .post('save', function(doc) {
    Project.update({_id: doc.project}, {$inc:  {numberSeq: 1}}, function(err, result) {
      if (err) {
        console.log(err);
      }
      console.log('Updated next number in seq for '  + doc.project);
    });
  });
  
  module.exports = mongoose.model('issues', IssueSchema);
  </code></pre>
  
  <p>And the route to insert the issue (I am guessing this isn't where the issue is)</p>
  
  <pre><code>app.post('/api/issue/create', function(req, res) {
  
      var issue = new Issues({
        title: req.body.title,
        description: req.body.description,
        fields: req.body.fields,
        attachments: req.body.attachments,
        project: req.body.project,
        created_by: req.user || req.body.created_by,
      });
  
      issue.save(function(err, result) {
        if (err) {
          return res.status(409).send({message: 'There was an error creating the issue: ' + err});
        }
        if (!result.number) {
          console.log('number = :(');
        }
        console.log(result);
        res.send({message: 'New issue created', result: result});
      });
    });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/m9RRx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m9RRx.png" alt="Screenshot of result from console with logging"></a></p>