title: MongoDB update not below zero
body: <p>I'm making a real time feature for my app which contains a set of items. Each user can get a certain amount of items but I'm wondering how I should handle this:</p>
  
  <pre><code>Items left: 7
  User A wants 5 items
  User B wants 5 items
  </code></pre>
  
  <p>And they both pressed the button on the exact same time.
  Because of the write/lock thing if I do this will only one person gets it? Or will they both get it and my items count will be -3 or?</p>
  
  <pre><code>var number = 5
      .update(
          {$where : "items &gt; number -1"},
          {$inc: {"items": -number}},
          {multi: true}
      );
  </code></pre>