title: "Cannot read property 'once' of undefined" when using trying to use gridfs for mongodb
body: <p>Im trying to use gridfs to upload files into my system.
  I am facing an issue in trying to connect mongodb to gridfs
  im only using the gridfs connection from its docs.
  app file :</p>
  
  <pre><code>// DB Config
  
  const db = require("./mongoos1.js");
  
  // Connect to MongoDB
  const conn = db.connect((err) =&gt; {
      if (err) {
          console.log('unable to connect to database');
          process.exit(1);
      }
  
      else {
          app.listen(5000, () =&gt; {
              console.log('connected to database, app listening on port 5000');
          });
      }
  });
  // Init gfs
  let gfs;
  
  conn.once('open', () =&gt; {
    // Init stream
    gfs = Grid(conn.db, mongoose.mongo);
    gfs.collection('uploads');
  });
  </code></pre>
  
  <p>Mongoose file:</p>
  
  <pre><code>const MongoClient = require('mongodb').MongoClient;
  const ObjectID = require('mongodb').ObjectID;
  const dbname = "FYP";
  const url = "mongodb://localhost:27017/FYP";
  const mongoOptions = { useNewUrlParser: true };
  
  const state = {
  
      db: null
  };
  
  
  const connect = (cb) =&gt; { // connect method
      if (state.db) //if there is connection
          cb();
      else { // if there isn't
          MongoClient.connect(url, mongoOptions, (err, client) =&gt; { // we use mongoclient to connect
              if (err)
                  cb(err);
              else {
                  state.db = client.db(dbname); // if no error , set state
                  cb();
              }
          });
      }
  }
  
  
  
  module.exports = { connect }; //exposing methods
  </code></pre>
  
  <p>am i making a mistake somewhere?</p>