title: How do I read the query in a mongoose callback?
body: <p>My code runs through a .forEach() loop over an array. Each iteration runs a mongoose query.</p>
  
  <p>My query is returning an empty object, which shouldn't happen, and I want to know why!</p>
  
  <p>I can't ask the callback to print the value used, as the forEach loop has completed by the time the promise resolves, so it just prints the last item of the array (which is the expected result).</p>
  
  <p>How can I access the query that was run in a mongoose callback?</p>
  
  <pre><code>array.forEach((item,i)=&gt;{
      model.findOneAndUpdate({a:item.a},item).exec((err,result)=&gt;{
          if(err){throw(err.stack);return;}
  
          if(!result)
              throw new Error("Nothing returned for query: "+QUERY_STRING)
      })
  })
  </code></pre>