Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions db/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ const connectedToDb = async () => {
return;
}

try {
await mongoose.connect(MONGO_URI, {
dbName: "leadllyQuestions",
});
console.log("Connected to db");
} catch (error) {
console.error("mongo error =========>", error);
}
try {
await mongoose.connect(MONGO_URI, {
dbName: "leadllyQuestions",
});
console.log("Connected to db");
} catch (error) {
console.error("Database connection error:", error);
process.exit(1); // Exit the application if the database connection fails
}
};

export default connectedToDb;