【发布时间】:2020-02-22 03:10:37
【问题描述】:
启动我的应用程序时,我收到以下警告:
(node:11800) DeprecationWarning: current Server Discovery and
Monitoring engine is deprecated, and will be removed in a future
version. To use the new Server Discover and Monitoring engine, pass
option { useUnifiedTopology: true } to the MongoClient constructor.
然而我们正在指定这个值:
connection = await mongoose.connect(dbUrl, {
keepAlive: true,
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true
});
dbUrl 的值为:mongodb://localhost:27017/test-app
环境:
mongo v4.0.13 on macOSnodejs v10.15.3package mongodb@3.3.2package mongoose@5.7.0
关于如何处理警告的任何想法?
【问题讨论】:
-
我认为这是在这里讨论过的:stackoverflow.com/questions/57895175/…
-
除了上面提到的链接,它拥有一切。您可以尝试通过
mongoose.set('useUnifiedTopology', true);明确设置 -
原来问题与我们测试中的一段代码有关,该代码直接使用 mongodb 包来删除数据库。我们需要确保参数在那里传递。