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

26 lines
857 B
JavaScript

import grabDSQLConnection from "../../grab-dsql-connection";
/**
* # DSQL user read-only DB handler
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
*/
export default async function DB_HANDLER(...args) {
var _a;
const CONNECTION = grabDSQLConnection();
try {
if (!CONNECTION)
throw new Error("No Connection provided to DB_HANDLER function!");
const results = await CONNECTION.query(...args);
return JSON.parse(JSON.stringify(results));
}
catch (error) {
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `DB_HANDLER Error`, error);
return {
success: false,
error: error.message,
};
}
finally {
await (CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end());
}
}