MongoDB connection in node js Application
import mongoose from "mongoose";
const PORT = process.env.PORT || 9000;
const connectToMongo = async () => {
const res = await mongoose.connect("mongodb://localhost:27017/blog-mern-app");
if (res) {
console.log("Data base connected succesfully");
}
};
export default connectToMongo;
// create Db.js file and call as middleware in index.js file
Post a Comment