backend/config/dbConnection.js

13 lines
361 B
JavaScript
Raw Normal View History

2023-09-13 16:36:17 +00:00
const mongoose = require('mongoose');
const connectDb = async () => {
await mongoose.connect(process.env.CONNECTION_STRING, {
}).then(() => {
console.log("Database connected: ", mongoose.connection.host, mongoose.connection.name);
}).catch((err) => {
console.log(err);
process.exit(1);
});
}
module.exports = connectDb;