Fixed db bug

The DB was moved to a different file and was returning a reference of the DB. When uploading a new database the original variable containing the DB in the DB file was not updating. Added setters and getters.
This commit is contained in:
2025-05-17 11:11:07 +03:00
parent f54d50674c
commit daadd58a5d
3 changed files with 34 additions and 20 deletions
+21 -7
View File
@@ -4,12 +4,26 @@ const db_conf = require("../config/db.conf");
var db;
try {
logger.info("Connecting to Database...");
db = new Database(db_conf.path, { fileMustExist: true });
logger.info("Connected to Database.");
} catch (error) {
logger.error(error.message);
function connect() {
try {
logger.info("Connecting to Database...");
db = new Database(db_conf.path, { fileMustExist: true });
logger.info("Connected to Database.");
} catch (error) {
logger.error(error.message);
}
}
module.exports = db;
function getDB() {
return db;
}
function setDB(newDb) {
db = newDb;
}
module.exports = {
connect,
getDB,
setDB,
};