title: Is there a way to check if a database exists in Mongo from the Node.js driver?
body: <p>I'm finding it surprisingly difficult to see find a way to see if a database exists or not in MongoDB from the Node.js driver. There <em>seems</em> to be no method in the Node.js driver to check if a database exists.</p>
  
  <p>For example, the following doesn't throw an error: </p>
  
  <pre><code>var mongo = require('mongodb').MongoClient;
  
  mongo.connect({ 'mongodb://localhost:27017/databaseThatDoesntExists }, function (err, db) {
     // There is no error
     if (err) console.log(err);
     // Let's get some stats on a database that doesn't exist
     db.statsAsync(function (err, result) {
        console.log(result);
     });
  });
  </code></pre>
  
  <p>Results will be an object like this: </p>
  
  <pre><code>{ db: 'databaseThatDoesntExist',
    collections: 0,
    objects: 0,
    avgObjSize: 0,
    dataSize: 0,
    storageSize: 0,
    numExtents: 0,
    indexes: 0,
    indexSize: 0,
    fileSize: 0,
    ok: 1 }
  </code></pre>
  
  <p>Can you check to see if a database exists in MongoDB form the Node.js driver?  Is there even a concept of a database existing in MongoDB? Is referencing a database that doesn't exist just referencing a database with no collections?</p>
  
  <p>Mongo, why can't you just throw an error! I like when my code <code>throws</code> errors!</p>