Posts

Showing posts from June, 2022

solved : Class constructor MongoStore cannot be invoked without 'new'

Image
                Solved :   Class constructor MongoStore cannot be invoked without 'new' Above screenshot you can see what is the problem ,  Solution :                         follow this code and fix this problem. this type Error is    showing  because  of we using old way to create session and storing in database . see this is guide  .          you have to use this for require:                const MongoStore = require ( 'connect-mongo' ); and Now use this as store data and create session :   // session for save in cart app. use (     session ({     secret: process.env.COOKIE_KEY, // database url     resave: false ,     saveUninitialized: false ,     cookie: {maxAge: 1000 * 60 * 60 * 24 }, // 24  hours ...

Solved : MongooseError: Operation `files.insertOne()` buffering timed out after 10000ms

Error : while connecting or inserting Data in MongoDB atlas Guys i have found a error when connecting to MongoDB atlas cloud. when i'm connecting to mongodb than my code is blow :   async function connectDB (){   try {     await mongoose . connect ( process . env . dbUrl ,() => console . log ( " Mongoose is connected" ),   );   } catch ( e ){     console . log ( e )   When we use above code than that is display : Mongoose is connected . b ut, when i want to insert document to mongoDB atlas cloud than showing a error like this : const err = new MongooseError(message); ^ MongooseError: Operation `files.insertOne()` buffering timed out after 10000ms at Timeout.<anonymous> (D:\expressJsBySujeet\fileShareBackend\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:151:23) if you want to don't see Like that error than use this two code :     useNewUrlParser : true , ...