From 27f476a8a730960596fb54a7ce8b907a4c703342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 28 Dec 2023 07:19:55 -0500 Subject: [PATCH] refactor(db): guard connexct statement instead --- lib/dbconfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dbconfig.ts b/lib/dbconfig.ts index f98879c..dd5a68a 100644 --- a/lib/dbconfig.ts +++ b/lib/dbconfig.ts @@ -14,4 +14,4 @@ export const olduri = ? `mongodb://127.0.0.1/rockfic_old?authSource=admin` : `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin`; -mongoose.connect(uri); +!mongoose.connection.modelNames().length && mongoose.connect(uri);