w、wtimeout、j 和 fsync 的顶级使用已弃用。改为使用 writeConcern

Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead

我正在使用带环回的 mongodb 并且在成功连接时我收到警告

Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.

环回版本:5.5.0

如何摆脱这个?请帮忙

显然这个警告是在 Mongo Driver v3.6.4 so the basis solution will be to down grade to v3.6.3. There is a PR that try to stop the warning outputs, and also a report on the Jira for the Node Driver. https://jira.mongodb.org/browse/NODE-3114

中引入的

更新: 该问题已在 3.6.5

版本中修复

传递以下选项

mongoose.connect(process.env.MONGO_URI, { 
  useNewUrlParser: true,
  useFindAndModify: false,
  useUnifiedTopology: true,
  useCreateIndex: true 
})