diff --git a/utils/db.js b/utils/db.js index acd9e73..a484caf 100644 --- a/utils/db.js +++ b/utils/db.js @@ -1,19 +1,21 @@ import mongoose from "mongoose"; let isConnected = false; -// const uri = "mongodb+srv://Arif:@cluster0.3tw6k.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"; -const localUri="mongodb://localhost/paste-buckets" +const uri = "mongodb+srv://Arif:6d4xHrDVMb7BrteV@cluster0.3tw6k.mongodb.net/Arif?retryWrites=true&w=majority"; +const localuri="mongodb://localhost/paste-buckets" + export const connect = async () => { if (!isConnected) { - await mongoose.connect( - localUri, - { - useNewUrlParser: true, - useUnifiedTopology: true, - useFindAndModify: false, - useCreateIndex: true, - } - ); + await mongoose.connect(localuri, { + + useNewUrlParser: true, + + useUnifiedTopology: true + + }, err => { + if(err) throw err; + console.log('Connected to MongoDB!!!') + }); isConnected = true; } -}; \ No newline at end of file +};