title: NodeJS + Mongo native – check if collection exists before query
body: <p>I've got a function, trying to get a specific value from settings collection in MongoDB. The marker for settings object, containing settings values, in settings collection is {'settings':'settings'}. The schema is:</p>
  
  <pre><code>collection:setting
  |--object
     |--{'settings':'settings'}
     |--{'valueA':'valueA'}
     |--...
  </code></pre>
  
  <p>The problem is when I first time query settings object, the collection 'settings' simply does not exists. So, </p>
  
  <pre><code>exports.getInstruments = function (callback) {
  db.collection("settings", function(error, settings) {
      settings.find({ "settings" : "settings" }), (function(err, doc) {
             callback(doc.instruments);
      }); 
  ]);  
  }
  </code></pre>
  
  <p>just hangs and callback is not invoked. If collection does not exist, I should return "" or undefined, else - doc.instrumens.</p>