Ive been getting a type error with my collection function that was working previously.
This code was working previously in my other project. I just ended up recycling alot of the code and now ive been getting this error. My mongodb connection code is in another file and is connected.
  var expect = require('chai').expect;
  var MongoClient = require('mongodb').MongoClient;
  var ObjectId = require('mongodb').ObjectId;
  var mongo    = require('mongodb').MongoClient;
  var db       = require('mongodb').MongoClient;
module.exports = function (app ,db) {
    db.collection.insertOne({
    "title": req.body.title,
    "_id": Math.random
  }).touchEvent(doc =>
    res.status(200).json({
      "status":"success",
     "_id": req.body._id,
      "title": req.body.title
    })).catch(err => {throw err;});
  })
};
The exact error message is "TypeError: Cannot read property 'collection' of undefined". Any help would be appreciated :)
 
     
     
    