Created
January 12, 2022 04:01
-
-
Save AkshayCHD/a4bbaa0e89243ff852b9b02510df0fc1 to your computer and use it in GitHub Desktop.
This file contains 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
const mongoose = require("mongoose"); | |
const username = "root"; | |
const password = "example"; | |
const dbname = "mongo-sinon"; | |
mongoose.connect( | |
`mongodb://${username}:${password}@localhost:27017/${dbname}?authSource=admin&readPreference=primary`, | |
{ | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
} | |
); | |
const db = mongoose.connection; | |
db.on("error", console.error.bind(console, "connection error: ")); | |
db.once("open", async function () { | |
console.log("Connected successfully"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment