解决办法:
//连接数据库
mongoose.set('useCreateIndex', true) //加上这个
mongoose.connect(db, { useNewUrlParser: true })
mongoose报错:DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
原文:https://www.cnblogs.com/nayek/p/12247069.html