mongoose .createConnection( mongoURI,{ useNewUrlParser: true }) .then(() => console.log("MongoDB connected")) .catch((err) => console.log(err)) code example
Example 1: mongoose connect
mongoose.connect('mongodb://localhost:27017/test', {
useMongoClient: true,
connectTimeoutMS: 1000
})
Example 2: mongoose.connect
mongoose.connect('mongodb://localhost:27017/myapp', {useNewUrlParser: true});