db.js
424 Bytes
import mongoose from "mongoose";
mongoose.connect(process.env.DB_URL,{
useNewUrlParser: true,
useFindAndModify: false,
useUnifiedTopology: true,
useCreateIndex: true
}
);
const db = mongoose.connection;
const handleOpen = () =>console.log("✅ Connected to DB");
const handleError = (error) =>console.log(`❌ Error on DB Connection:${error}`);
db.once("open", handleOpen);
db.on("eror",handleError);