Skip to content

Instantly share code, notes, and snippets.

@manojnaidu619
Created April 4, 2020 05:13
Show Gist options
  • Save manojnaidu619/c644631154e64f8ce97bdf3ffaef4b94 to your computer and use it in GitHub Desktop.
Save manojnaidu619/c644631154e64f8ce97bdf3ffaef4b94 to your computer and use it in GitHub Desktop.
MongoDB database connection code snippet
const mongodb = require("mongodb")
const MongoClient = mongodb.MongoClient
const connectionURL = "mongodb://127.0.0.1:27017" // Change the url in production
const databaseName = "task-manager" // Change the database name
MongoClient.connect(connectionURL, { useNewUrlParser: true, useUnifiedTopology: true }, (error, client) => {
if (error) {
return console.log("Some error occurred")
}
console.log("Connection acquired!")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment