title: mongodb update a key to all documents using forEach
body: <p>I want to update in <code>Mongo</code> the 'order' field to all of my documents so they will be 1..2..3..4....34.</p>
  <p>After running this, they all have &quot;order&quot;: &quot;34&quot;.
  What am I doing wrong?</p>
  <pre><code>var i = 1;
  db.images.find().forEach(function() {
      db.images.update(
          {},
          { &quot;$set&quot;: {&quot;order&quot;: NumberInt(i)} },
          { multi: true }
      );
      i++;
  })
  </code></pre>