title: Node.js:Typeerror cannot read property 'find' of undefined
body: <p>I've been doing some research within these couple of days but got stuck while trying to test the codes that I got from the web.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var MongoClient = require('mongodb').MongoClient,
    format = require('util').format;
  
  MongoClient.connect('mongodb://127.0.0.1:27017/test', function(err, db) {
    if (err) {
      throw err;
    } else {
      console.log("successfully connected to the database");
      db.collection('chat', function(err, collection) {
      
        collection.find({}, {
            tailable: true,
            awaitdata: true,
            numberOfRetries: -1
          })
          .sort({
            $natural: 1
          })
          .each(function(err, doc) {
            console.log(doc);
          })
      });
  
  
    }
    db.close();
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>And the error is:
  c:\Project\node_modules\mongodb\lib\mongo_client.js:406
            throw err
                  ^
  Am I missing any external library/reference because the error says "<strong>Cannot read property 'find' of undefined</strong>".</p>
  
  <p>mongodb version: "2.0.31"</p>