title: Cannot read property 'collection' of null
body: <p>Here is my code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Retrieve
  var MongoClient = require('mongodb').MongoClient;
  
  // Connect to the db
  
  MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) {
    if(!err) { 
       console.log('we are connected'); 
    }
  
    var k ='testt';
    var collection = db.collection(k);
    var doc1 = {'hello':'doc1'};
    var doc2 = {'hello':'doc2'};
    var lotsOfDocs = [{'hello':'doc3'}, {'hello':'doc4'}];
  
    collection.insert(doc1);
  
    collection.insert(doc2, {w:1}, function(err, result) {});
  
    collection.insert(lotsOfDocs, {w:1}, function(err, result) {});
  
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>and it is is showing this error "Cannot read property 'collection' of null".</p>