datasquirel/package-shared/utils/backend/global-db/LOCAL_DB_HANDLER.ts
Benjamin Toby b38ddc9f21 Updates
2025-07-06 15:32:28 +01:00

23 lines
595 B
TypeScript

import grabDSQLConnection from "../../grab-dsql-connection";
/**
* # DSQL user read-only DB handler
*/
export default async function LOCAL_DB_HANDLER(query: string, values?: any[]) {
const MASTER = grabDSQLConnection();
try {
const results = await MASTER.query(query, values);
return JSON.parse(JSON.stringify(results));
} catch (error: any) {
global.ERROR_CALLBACK?.(`LOCAL_DB_HANDLER Error`, error as Error);
return {
success: false,
error: error.message,
};
} finally {
await MASTER?.end();
}
}