Created
June 29, 2023 02:08
-
-
Save Kasun002/f7fc0ae0ffc085b4a5f2cb41bc0dfa46 to your computer and use it in GitHub Desktop.
Express JS project Mongo-DB connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose'; | |
const dbUri = "Your mongo DB URI" // This should be prick from .env file | |
export default async () => { | |
await mongoose.connect(dbUri,{}) | |
.then(() => { | |
console.log('Mongodb Connection to database'); | |
}) | |
.catch(err => { | |
console.log(err); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment