Skip to content

Instantly share code, notes, and snippets.

@mirsahib
Created August 14, 2019 14:32
Show Gist options
  • Save mirsahib/0b7c50236837126b5cedba8cde1c1d1b to your computer and use it in GitHub Desktop.
Save mirsahib/0b7c50236837126b5cedba8cde1c1d1b to your computer and use it in GitHub Desktop.
//database setting
var db_url =
"mongodb+srv://mirsahib24:[email protected]/rotten-pumpkin?retryWrites=true&w=majority";
mongoose.connect(db_url, { useNewUrlParser: true });
mongoose.connection.on("error", function(err) {
console.log(err);
console.log("Could not connect to mongodb");
});
mongo.MongoClient.connect(db_url, { useNewUrlParser: true }, function(
err,
client
) {
if (err) {
console.log("Could Not Connect DB");
} else {
db = client.db("Test");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment