title: How do I access document object in pre update mongoose middle-ware?
body: <p>consider, I have a mongoose schema like this</p>
  
  <pre><code>const mySchema = new mongoose.schema({
  val1:Number,
  val2:Number
  val_1_isBigger:Boolean})
  </code></pre>
  
  <p>Now I want to compare both the val1 &amp; val2 before every update opearation and accordingly I wanna set Boolean attribute for val_1_isBigger.</p>
  
  <p><strong>My question is how do I access document object during pre('update') mongoose plugin operation. Look at following example</strong></p>
  
  <pre><code>mySChema.plugin(function(schema, options) {
      schema.pre('update', function(next) {
  
  //Here How Do I compare val1 &amp; val2 before update happens
  //and then set value here accordingly
  
    this.update({}, { $set: { val_1_isBigger: true/false } });
  
  }
  }
  </code></pre>