you need to install mongoose from npm by this command:
npm install –save mongoose
then,include following line of code:
var mongoose = require( ‘mongoose’ );
var db =
mongoose.createConnection(‘mongodb://localhost:27017/dbname’);db.on(‘connected’, function () { logger.info(‘Mongoose connection open to master DB – ‘+ ‘mongodb://localhost:27017/dbname’); });
module.exports = db;
1
solved NodeJS MongoDB Connection