Created
November 12, 2021 14:49
-
-
Save omitobi/41df533868583db7506fd5e64cfc2326 to your computer and use it in GitHub Desktop.
connect to mongo once
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
await mongoose.connect(dbUrl, { | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
useCreateIndex: true, | |
useFindAndModify: false, | |
}); | |
const connection = mongoose.connection; | |
connection.once("open", function() { | |
console.log("MongoDB database connection established successfully"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment