datasquirel/dist/package-shared/utils/backend/global-db/ROOT_DB_HANDLER.js
Benjamin Toby 7e8bb37c09 Updates
2025-07-05 14:59:30 +01:00

35 lines
1009 B
JavaScript

import grabDSQLConnection from "../../grab-dsql-connection";
/**
* # Root DB handler
*/
export default function ROOT_DB_HANDLER(...args) {
var _a;
const CONNECTION = grabDSQLConnection();
try {
return new Promise((resolve, reject) => {
CONNECTION.query(...args)
.then((results) => {
CONNECTION.end();
resolve(JSON.parse(JSON.stringify(results)));
})
.catch((err) => {
CONNECTION.end();
resolve({
error: err.message,
sql: err.sql,
});
});
});
}
catch (error) {
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `ROOT_DB_HANDLER Error`, error);
return {
success: false,
error: error.message,
};
}
finally {
CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end();
}
}