title: Type Error: Cannot read property 'hasListCollectionsCommand' of null
body: <p>I'm trying to get all collection names in mongodb (v4.0.2) and using <a href="https://www.npmjs.com/package/mongodb" rel="nofollow noreferrer">mongodb@3.1.10</a> nodejs driver. From the docs, I can see that <code>listCollections</code> might work, but running the following:</p>
  
  <pre><code>const Db = require('mongodb').Db
  const Server = require('mongodb').Server
  const db = new Db(dbName, new Server(host, port, options), {})
  db.listCollections().toArray((error, collectionNames) =&gt; {
    console.error(error)
    console.log(JSON.stringify(collectionNames))
  })
  </code></pre>
  
  <p>… leads to this error:</p>
  
  <blockquote>
    <p>if (this.serverConfig.capabilities().<strong>hasListCollectionsCommand</strong>) {<br>
    TypeError: Cannot read property 'hasListCollectionsCommand' of null<br>
    &nbsp;&nbsp;&nbsp;at Db.listCollections ({path}/node_modules/mongodb/lib/db.js:493:39)<br>
    &nbsp;&nbsp;&nbsp;at db.createCollection ({path}/sampleMongoDB.js:19:8)<br>
    &nbsp;&nbsp;&nbsp;at err ({path}/node_modules/mongodb/lib/utils.js:415:14)<br>
    &nbsp;&nbsp;&nbsp;at executeCallback ({path}/node_modules/mongodb/lib/utils.js:404:25)<br>
    &nbsp;&nbsp;&nbsp;at executeOperation ({path}/node_modules/mongodb/lib/utils.js:422:7)<br>
    &nbsp;&nbsp;&nbsp;at Db. ({path}/node_modules/mongodb/lib/db.js:431:12)<br>
    &nbsp;&nbsp;&nbsp;at Db.deprecated [as createCollection] ({path}/node_modules/mongodb  /lib/utils.js:661:17)<br>
    &nbsp;&nbsp;&nbsp;at Object.&lt; anonymous > ({path}/sampleMongoDB.js:18:6)<br>
    &nbsp;&nbsp;&nbsp;at Module._compile (module.js:653:30)<br>
    &nbsp;&nbsp;&nbsp;at Object.Module._extensions..js (module.js:664:10)</p>
  </blockquote>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Is there a docs site for MongoDB NodeJs drivers where we can refer examples from?</li>
  <li>If not, what's the correct way to query?</li>
  </ol>