Uninstalling existing mongodb package and reinstalling using the following commands resolved the issues
npm uninstall mongodb --savenpm install mongodb@2.2.33 --save
Version MongoDB >= 3 - That database variable is actually the parent object of the object you are trying to access. If u using mongo 3+:
const myDb = db.db('YourDatabase') myDb.collection('YourDatabase).insertOne ....