title: Mongoose pushing to an Array using presave middleware
body: <p>I'm trying to update an array using presave hooks available in mongoose. Im using this array for Audit Purposes and hence i wanted to enforce correct values using these middle wares</p>
  
  <p>Here is my schema </p>
  
  <pre><code>const taskSchema = new mongoose.Schema({
  id: { type: String, required: true },
  status: { type: String, required: true },
  code: { type: String, required: true }, // ENQUIRY
  events:{
      type:[{
              status: {type: String, required: true},
              date:{ type: Date, required: true}
  
      }], required: false
  },
  assignedTo: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: false },
  }, {timestamps:true});
  </code></pre>
  
  <p>The logic works great in save middleware hook.</p>
  
  <pre><code>taskSchema.pre('save', async function(next) {
      try {
          let event = {}
          let now = Date.now();
          event.status = this.status;
          event.date = now;
          this.events.push(event);
          next();
      } catch (error) {
          console.log(error);
          next(error);
      }
  });
  </code></pre>
  
  <p>Error when used in findOneAndUpdate hook</p>
  
  <pre><code>taskSchema.pre('findOneAndUpdate', async function(next) {
      try {
  
          let event={}
          let now = Date.now();
          event.status = this._update.status;
          event.date = now;
          this.events.push(event);
          next();
      } catch (error) {
          console.log(error);
          next(error);
      }
  });
  </code></pre>
  
  <p>I'm not sure what I'm missing here.  Here is the error</p>
  
  <pre><code>TypeError: Cannot read property 'push' of undefined 
  </code></pre>
  
  <p>I see that this.events is undefined. </p>
  
  <p>How do I access that array to have it updated?  I also should ignore whatever is sent in request.body.events </p>
  
  <p>Thanks in advance. </p>