Skip to content

Instantly share code, notes, and snippets.

@hamzaajaved
Created September 14, 2021 05:25
Show Gist options
  • Select an option

  • Save hamzaajaved/5d0c57c7115f6fdabf49ea1a04fde026 to your computer and use it in GitHub Desktop.

Select an option

Save hamzaajaved/5d0c57c7115f6fdabf49ea1a04fde026 to your computer and use it in GitHub Desktop.
mongoose.connect('mongodb://localhost:27017/my-app', {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true
});
const db = mongoose.connection;
db.on("error", console.error.bind(console, "connection error:"));
db.once("open", () => {
console.log("Database connected");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment