title: mongodb TypeError: client.db.collection is not a function
body: <p>when I use "mongodb": "^3.0.5",</p>
  
  <pre><code>    const cn = require('./connect');
  
      function showItems(req, callback) {
        cn.MongoClient.connect(cn.url, (err, database)=&gt; {
  
          const collection = database.db.collection('items');
  
          collection.find({}).toArray((err, result)=&gt; {
  
            callback(result);
          });
  
          database.close();
        })
      }
  
      module.exports = showItems;
  </code></pre>
  
  <p>I got,</p>
  
  <blockquote>
    <p>/node_modules/mongodb/lib/mongo_client.js:433</p>
    
    <p>throw err</p>
    
    <p>^</p>
    
    <p>TypeError: database.db.collection is not a function</p>
  </blockquote>
  
  <p>But,when I use "mongodb": "^2.2.33" , it worked.</p>
  
  <pre><code>    const cn = require('./connect');
  
      function showItems(req, callback) {
        cn.MongoClient.connect(cn.url, (err, db)=&gt; {
  
          const collection = db.collection('items');
  
          collection.find({}).toArray((err, result)=&gt; {
  
            callback(result);
          });
  
          db.close();
        })
      }
  
      module.exports = showItems;
  </code></pre>
  
  <p>connect.js</p>
  
  <pre><code>    const url = "mongodb://127.0.0.1:27017/databasename";
      const MongoClient = require('mongodb').MongoClient;
  
      module.exports = {url, MongoClient};
  </code></pre>
  
  <p>Use "mongodb": "^3.0.5" , How to solve this problem ?</p>