title: Call function in document insert
body: <p>I am trying to create "server side function" (custom JS function loaded in Mongo db) according to <a href="http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/#auto-increment-counters-collection" rel="nofollow">autoincrement tutorial</a>. 
  The main idea is to have function getNextSequence(collectionName), which returns autoincrement id for this collection. Trick is to have separate collection "counters" with document for each collection, that holds autoincrement status.</p>
  
  <p>Anyway, I have created and loaded that function in Mongo and it works nicely via Mongo shell:</p>
  
  <pre><code>db.users.insert(
     {
       _id: getNextSequence("userid"),
       name: "Sarah C."
     }
  )
  </code></pre>
  
  <p>It also works from NodeJS via eval:</p>
  
  <pre><code>db.eval('getNextSequence(\'test\')', function(err, result){...});
  </code></pre>
  
  <p>But I can't figur out, how to use it inline in document when inserting from NodeJS. 
  I cannot write: </p>
  
  <pre><code>   {
       _id: getNextSequence("userid"),
       name: "Sarah C."
     }
  </code></pre>
  
  <p>as this would expect getNextSequence to be NodeJs method. Is there any expression form in NodeJS+MongoDB for this?
  Thanks!</p>