From 927405f85870b08b972846a4153ac80045af4c6d Mon Sep 17 00:00:00 2001 From: LingandRX Date: Mon, 30 Dec 2024 22:25:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(config):=20=E7=A7=BB=E9=99=A4=20MongoD?= =?UTF-8?q?B=20=E8=BF=9E=E6=8E=A5=E4=B8=AD=E7=9A=84=E5=86=97=E4=BD=99?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了 mongoose.connect 中的 useNewUrlParser 和 useUnifiedTopology 配置项 - 这些配置项在新版的 mongoose 中已经默认启用,无需显式设置 --- config/mongodbConfig.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config/mongodbConfig.js b/config/mongodbConfig.js index 0bafb37..0ef2854 100644 --- a/config/mongodbConfig.js +++ b/config/mongodbConfig.js @@ -23,10 +23,7 @@ exports.connectMongoDB = async function () { try { const mongoDBUrl = `mongodb://${account}:${password}@${host}:${port}` - mongoose.connect(mongoDBUrl, { - useNewUrlParser: true, - useUnifiedTopology: true - }) + mongoose.connect(mongoDBUrl) mongoose.connection.on('open', () => { console.log('MongoDB 连接成功')