`Error TypeError: Class constructor MongoStore cannot be invoked without 'new'
** MY code is:**
const url = 'mongodb://localhost/pizza';
mongoose.connect(url, { useNewUrlParser: true, useUnifiedTopology: true });
const connection = mongoose.connection;
mongoose.connection
.once('open', function () {
console.log('Database connected');
})
.on('error', function (err) {
console.log(err);
});
// session
let mongoStore = new MongoDbStore({
mongooseConnection: connection,
collection: 'sessions'
})```
```// session config
app.use(session({
secret: process.env.COOKIE_SECRET,
resave: false,
store: mongoStore,
saveUninitialized: false,
cookie: { maxAge: 1000 * 60 * 60 * 24 } // 24 hour
}))```
`
**This is the error i am getting **`
const MongoDbStore = require('connect-mongo')(session) ^
TypeError: Class constructor MongoStore cannot be invoked without 'new' at Object. (C:\Projects\pizza\server.js:21:46) at Module._compile (node:internal/modules/cjs/loader:1126:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) at Module.load (node:internal/modules/cjs/loader:1004:32) at Function.Module._load (node:internal/modules/cjs/loader:839:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47
`Please help to solving the error `
`**I tried some solution from thee stackOverflow but still not able to solve the problem**`