CodeWithHarry / iNotebook-React

INotebook is a React Application for managing personal notes on the cloud
343 stars 193 forks source link

In db.js MONGODB no longer wants a callback function, Go for this #64

Open khelan-mehta opened 1 year ago

khelan-mehta commented 1 year ago
const connectToMongo = ()=>{
    try{
        mongoose.connect(mongoURI)
        console.log("SUCCESSFULLY CONNECTED DB");
    }catch(error){
        console.log(error);
    }

}
PrakharDsek commented 1 year ago

this error means that in latest version of mongo db there is no need of a callback function

On Tue, Sep 5, 2023 at 5:01 PM Khelan Mehta @.***> wrote:

const connectToMongo = ()=>{ try{ mongoose.connect(mongoURI) console.log("SUCCESSFULLY CONNECTED DB"); }catch(error){ console.log(error); }

}

— Reply to this email directly, view it on GitHub https://github.com/CodeWithHarry/iNotebook-React/issues/64, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZIEULYNPOTLER4O4BWSJE3XY4EQ3ANCNFSM6AAAAAA4LUHA4Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

pratahmesh commented 10 months ago

This will Resolve Your Issuse `const mongoose = require('mongoose');

const connectToMongo = async ()=>{ try{ mongoose.set('strictQuery',false) await mongoose.connect("mongodb://localhost:27017") console.log('Mongo connected') }catch(error){ console.log(error) process.exit() } }

module.exports = connectToMongo;`