If you facing problem in mongoose while creating connection with following two warning: 1. DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. 2. DeprecationWarning: useNewUrlParser: true
Then you can use use following two line of code to avoid this issue:
mongoose.set('useNewUrlParser',true);
mongoose.set('useCreateIndex',true);
mongoose.connect(dbURI)
.then(connection => {
console.log('Connected to MongoDB DB')
})
.catch(error => {
console.log(error.message)
})