title: meteor how to manage async updates in a loop
body: <p>I have this loop:</p>
  
  <pre><code>properties.forEach(function(property) {
      console.log("property: " + property);
      var upsertValues = {};
      upsertValues["ID"] = property.ID;
      Properties.upsert(upsertValues,
          {$set: property}, 
          function(err, nbr) {
              if(err)
                  console.log(err);
              else
                  console.log("upsert successful" + nbr);
          });
      });
      setTimeout(function () {
          Fiber(function() {
              Meteor.call("removeOldProperties", modification_date);
          }).run();
      }, 30000)
  })
  </code></pre>
  
  <p>Basically, it updates a bench of documents and at the end, it removes all the once who have not been updated.</p>
  
  <p>I had to use a TimeOut because without that, I removes the documents before their update, as all the Meteor.upsert statements are async.</p>
  
  <p>Is there a better way to do it (without having to use this timeout) ?</p>
  
  <p>Thanks,</p>