title: MongoDb TypeError: Cannot read property 'insertMany' of undefined
body: <pre><code>import { MongoClient } from 'mongodb';
  import assert from 'assert';
  import config from './config';
  
  
  console.log('Inside File');
  MongoClient.connect(config.mongodbUri, (err, db) =&gt; {
    assert.equal(null, err);
  
  
   db.products.insertMany( [
        { item: "card", qty: 15 },
        { item: "envelope", qty: 20 },
        { item: "stamps" , qty: 30 }
     ] ); 
        db.close();
  
  });
  </code></pre>
  
  <p>For the above code i get the error Cannot read property insertMany of undefined.
  But when i just enter the below</p>
  
  <pre><code> db.products.insertMany( [
        { item: "card", qty: 15 },
        { item: "envelope", qty: 20 },
        { item: "stamps" , qty: 30 }
     ] ); 
  </code></pre>
  
  <p>in the console the products seems to get inserted in the db just fine.
  Can someone please let me know the cause of this issue?</p>