Skip to content

Instantly share code, notes, and snippets.

@omitobi
Created November 12, 2021 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omitobi/41df533868583db7506fd5e64cfc2326 to your computer and use it in GitHub Desktop.
Save omitobi/41df533868583db7506fd5e64cfc2326 to your computer and use it in GitHub Desktop.
connect to mongo once
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