title: update multiple documents with mongodb
body: <p>How to iterate an array of objects to update documents with mongodb and <strong>keep the modified documents to return back in the response</strong></p>
  
  <p>Notice the comments in the code</p>
  
  <pre><code>.put(function (req, res) {
  
      var data = req.body.data;
      var documents = [];
      for (var item in data) {
  
          var id = data[item]._id;
          var document = data[item];
  
          Item.update({ _id: id }, document, { overwrite: true }, function (err, item) {
            if (err) {
              res.send({'error':'Error'});
            }
            Item.findById(id, function (err, document) {
              if (err) {
                res.send({});
              }
              documents.push(document); // documents are pushed
            });
  
          });        
      }
      documents ; // value is []
      res.json({
        items: documents
      });        
  }) 
  </code></pre>