1mongoose.connect('mongodb://localhost:27017/test', {
2 useMongoClient: true,
3 connectTimeoutMS: 1000
4})
1try {
2 mongoose.connect(MONGODB_URI || 'mongodb://localhost/YOUR_DB_NAME', {
3 useNewUrlParser: true,
4 useUnifiedTopology: true
5 }, () =>
6 console.log("connected"));
7} catch (error) {
8 console.log("could not connect");
9}
1mongoose.connect('mongodb://username:password@host:port/database?options...', {useNewUrlParser: true});