backend/config/dbConnection.js
2023-09-13 23:36:17 +07:00

13 lines
No EOL
361 B
JavaScript

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;