TypeError: Cannot read property 'databaseName' of undefined TypeError: Cannot read property 'databaseName' of undefined mongoose mongoose

TypeError: Cannot read property 'databaseName' of undefined


It might be a problem with the 'express.bodyParser()', you have to define your connections AFTER all the configuration of your app.


In db.js,

module.exports = mongoose.connections;

change to:

module.exports = mongoose.connections[0];


You can just reuse the db object already instantiated by mongoose!

new MongoStore({  db: mongoose.connection.db})