title: Mongoose - FindOne() inside Multer
body: <p>I am sending formData to my express app like so:</p>
  
  <pre><code>itemFactory.saveItem = function(item, callback){
  
      var formData = new FormData();
  
      for(var i = 0; i &lt; item.photos.length; i++){
          formData.append('photos', item.photos[i]);
      }       
      for(var key in item){
          formData.append(key, item[key])     
      }
  
      return $http.post('/api/item/', formData, {
          transformRequest: angular.identity,
          headers: { 'Content-Type': undefined }
      }).success(callback);
  
  };
  </code></pre>
  
  <p>I am saving a new item to my mongoose DB.  Now everything is working perfectly.  But I want to detect duplicates using mongoose <code>findOne()</code>, and not just let mongoose handle detecting if a duplicate key exists when writing to the DB.  Because my images get uploaded regardless at this stage, if a duplicate key exists or not.  Because it only detects the duplicate on <code>save()</code></p>
  
  <p>The problem now, in my express app, is when I am using <code>findOne()</code>, Multer() has not yet decoded my formData. ex:</p>
  
  <pre><code>router.post('/item', function(req, res){
      Vehicle.findOne({ id: String(req.body.id) }, function(error, item){
  
          var storage = multer.diskStorage({...})
          var upload = multer({
                           storage: storage
                       }).any();
  
          upload(req, res, function(error){
              //formData is only available here via req.body
              //and not at findOne() stage.
          });
  
      });
  });
  </code></pre>
  
  <p>I cannot do the findOne inside the upload because then the files would be uploaded anyway and then only detect a duplicate.</p>
  
  <p>I tried another <code>multer().any()</code> function for getting the formData just after the <code>.post()</code> but that did not seem to work.  I don't think I can do this:</p>
  
  <pre><code>var detectItem = multer().any()
  detectItem(req, res, function(){
  
      Vehicle.findOne({ id: String(req.body.id) }, function(error, item){
  
          var storage = multer.diskStorage({...})
          var upload = multer({
                           storage: storage
                       }).any();
  
          upload(req, res, function(error){
              //formData is only available here via req.body
              //and not at findOne() stage.
          });
  
  })
  </code></pre>
  
  <p>It does not seem to like me using a multer function inside a multer function.</p>
  
  <p>Any advice?</p>