title: call db.loadServerScripts on connection startup
body: <p>I have some <a href="http://docs.mongodb.org/manual/tutorial/store-javascript-function-on-server/" rel="nofollow">server-side helper functions</a> in system.js collection, which are then used in node.js. However sometimes, they are undefined. </p>
  
  <p>Here is the scenario:
  I load these functions once, on server start:</p>
  
  <pre><code>db.eval('db.loadServerScripts()', function(err, result) { ... });   
  </code></pre>
  
  <p>So this is called only once on start, not for every request.</p>
  
  <p>From now on I can call e.g.:</p>
  
  <pre><code>db.eval('getNextSequence(\'test\')', function(err, seq){});
  </code></pre>
  
  <p>But sometimes I get the error, that getNextSequence is undefined. I suspect those functions to exist only in current connection scope. So maybe when node receives new connection, the functions are not set.</p>
  
  <p>Is there any way to use those functions in node.js, but to have them reliably available always?</p>
  
  <hr>
  
  <p>Example scenario:</p>
  
  <pre><code>//1./ this function is stored in system.js
  getNextSequence: function(name) 
  {
      var ret = db.counters.findAndModify({
          query: { _id: name },
          update: { $inc: { seq: 1 } },
          new: true,
          upsert: true
      });
      return ret ? ret.seq : null;
  }
  
  //2./ this is called on nodejs server startup (once for server lifetime)
  var mongo = require('mongoskin');
  var db = mongo.db("mongodb://localhost:27017/mydb", {native_parser:true});
  //...
  db.eval('db.loadServerScripts()', function(err, result) {
      //...crash if failed
  }); 
  
  //3./ this is used in node.js code, on request processing:
  db.eval('getNextSequence(\'someNamespace\')', function(err, seq){
      // int seq is converted to string slug
      // a new entity with slugId is saved to collection
  });
  </code></pre>