title: Transactional behavior with mongoose
body: <p>Let's say I have a schema <code>A</code> in mongoose. It looks like this:</p>
  
  <pre><code>{
      arr: [{
          num: Number,
          text: String
      }]
  }
  </code></pre>
  
  <p>Now I want to perform the following action:</p>
  
  <ol>
  <li><p>Select an <code>A</code> namely <code>a</code>.</p></li>
  <li><p>Get the actual count of <code>a.arr</code>'s items.</p></li>
  <li><p>Add a new element to <code>a.arr</code>, with the count and a text.</p></li>
  </ol>
  
  <p>My implementation:</p>
  
  <pre><code>A.findOne({_id: someId}, function(err, a) {
      var count = a.arr.length;
      a.push({
          count: count,
          text: 'some text'
      });
      a.save(...)
  });
  </code></pre>
  
  <p>Works fine so far.
  But my problem:
  If I execute that concurrent, let's say with 5 processes, some processes execute <code>findOne</code> before the others saved.
  So count is 0 for the first few, and then when they have saved, it gets immediately 3 or 4 for the next processes.</p>
  
  <p>But I want that to execute serial.</p>
  
  <p>How to achieve that?</p>
  
  <p>Thanks!</p>