title: NodeJs Mongoose passing parameters to post findOneAndUpdate
body: <p>I want to use post findOneAndUpdate middlewares to save a log datas of all my mongoose model changes.<br><br> </p>
  
  <blockquote>
    <blockquote>
      <p>I use findOneAndUpdate in three places:</p>
    </blockquote>
  
  <pre><code> - Update Model's data
   - change Model status
   - archive / restore Model
  </code></pre>
  </blockquote>
  
  <p>So when I use the post findOneAndUpdate middlewares, I want to Knwo wich one of the three findOneAndUpdate was executed.</p>
  
  <p>Is there a way to pass parameters from findOneAndUpdate to post findOneAndUpdate middlewares.?</p>
  
  <p>There is my Code:</p>
  
  <p><strong>controller</strong>: invoices.js</p>
  
  <pre><code>    update: function (request, response, next) {
      //checking general invoice information
      request.checkBody(typeValidationSchema);
      request.getValidationResult().then(function(result) {
          if (!result.isEmpty()) return response.apiError(result.array());
          else {
              Invoice.findOneAndUpdate({
                  _id: request.params.invoiceId,
                  createdBy: request.user._id
              }, request.body, {'new': true, 'runValidators': true}).exec(function (error, invoice) {
                  if (error) response.apiError(error);
                  if (!invoice) return response.apiNotFound();
                  else return response.apiResponse(invoice);
              });
          }
      });
  },
  </code></pre>
  
  <p><strong>Model Schema</strong>: invoice.js</p>
  
  <pre><code>InvoiceSchema.post('findOneAndUpdate', function(doc) {
  // I want to get her some variables passed from controller findOneAndUpdate
  });
  </code></pre>