title: auto increment in node-mongodb-native using counters collection
body: <p>Is there any way of implementing a <a href="http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/#auto-increment-counters-collection" rel="nofollow">counters collection</a> as described in the docs with node-mongodb-native?</p>
  
  <p>I'm trying to avoid doing this by nesting over 9000 callbacks (which IMHO sounds untidy and not-elegant) but the good people who wrote this native driver refused to implement synchronous/blocking calls.</p>
  
  <p>Does the native driver provide a someway to call user defined functions and use their return values during queries? Or could there be an alternate way of extracting a sequential count....maybe solely from an <code>ObjectID()</code>?</p>
  
  <p>Any ideas?</p>
  
  <p><b>EDIT:</b> <br>
  This is not for the <code>_id</code> field (That's taken care of by <code>db.coll.save(x)</code>)<br>
  I have different types of documents in a collection. Each of these needs its own "type serial" or "type sequence" if you know what i mean.</p>
  
  <p>I've already implemented this (plus other stuff) with afew nested calls as shown bellow. <code>doc</code> is <code>JSON.parse</code>'d from the client. I have to return this <code>doc</code> to the client with an <code>_id</code> (sorted by <code>db.coll.save</code>) and with a <code>typeserial</code> (currently being sorted by <code>db.coll.count</code> as shown bellow)</p>
  
  <pre><code> ///more nesting Async calls above. 
   db.collection('dox').count( { "type" : doc.type } ,
      function( err , count )
      {
          ///{some err checking code here}
          doc.typeseq = (1+count);
          db.collection('dox').save( doc ,
              function( err , doc )
              {
                  ///{more code here}
                  ///Finally return JSON.stringified doc with new info/members to client-side
              }
          );
      }
   );
  </code></pre>
  
  <p>I'd just like to know if there is a more elegant, anti-async way of getting my <code>doc.typeserial</code></p>