From 69b20c3096a2ef6d2965b54da238a39961e7ee0c Mon Sep 17 00:00:00 2001 From: ajibadeabd <43596899+ajibadeabd@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:13:40 +0100 Subject: [PATCH] added condition to either connect to local db when server set to localhost --- helpers/ORMs/Mongoose/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/helpers/ORMs/Mongoose/index.js b/helpers/ORMs/Mongoose/index.js index 05843fa..d76dc2d 100644 --- a/helpers/ORMs/Mongoose/index.js +++ b/helpers/ORMs/Mongoose/index.js @@ -8,18 +8,18 @@ require("./schemas/users"); require("./schemas/oauthtokens"); - +const mongoServer = server == "localhost" ? + `mongodb://${server}:27017/${database}` : + `mongodb+srv://${username}:${password}@${server}/${database}` class Database { constructor() { this.Mongoose = mongoose; this._connect(); + } _connect() { - this.Mongoose.connect( - "mongodb://localhost:27017/salla-db" - // `mongodb+srv://${username}:${password}@${server}/${database}` - ) + this.Mongoose.connect(mongoServer ) .then(() => { console.log("Database connection successful"); })