From 17825656924ca7dee40880b8343f269509f48f89 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Sat, 10 Jun 2023 22:54:11 +0000 Subject: [PATCH] compose db conn params --- shared/classes/DbManager/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/shared/classes/DbManager/index.js b/shared/classes/DbManager/index.js index 9725bf98..7c85ca66 100755 --- a/shared/classes/DbManager/index.js +++ b/shared/classes/DbManager/index.js @@ -19,19 +19,22 @@ function getConnectionConfig(obj) { auth.push("/?authMechanism=DEFAULT") } - if (DB_AUTH_SOURCE && DB_USER) { - auth.push(`&authSource=${DB_AUTH_SOURCE}`) + auth = auth.join("") + + const params = { + auth: {}, + dbName: DB_NAME, + useNewUrlParser: true, + useUnifiedTopology: true, } - auth = auth.join("") + if (DB_AUTH_SOURCE) { + params.auth.authSource = DB_AUTH_SOURCE + } return [ auth, - { - dbName: DB_NAME, - useNewUrlParser: true, - useUnifiedTopology: true, - } + params, ] }