This works for me nicely:
mongoose.set("useNewUrlParser", true);
mongoose.set("useUnifiedTopology", true);
mongoose
.connect(db) //Connection string defined in another file
.then(() => console.log("Mongo Connected..."))
.catch(() => console.log(err));