2025-01-14 15:27:08 +00:00
|
|
|
import grabDSQLConnection from "../../grab-dsql-connection";
|
2024-11-26 09:31:39 +00:00
|
|
|
|
|
|
|
/**
|
2025-01-13 08:00:21 +00:00
|
|
|
* # DSQL user read-only DB handler
|
2024-11-26 09:31:39 +00:00
|
|
|
*/
|
2025-01-13 08:00:21 +00:00
|
|
|
export default async function LOCAL_DB_HANDLER(...args: any[]) {
|
2025-01-14 15:27:08 +00:00
|
|
|
const MASTER = grabDSQLConnection();
|
2024-11-26 09:31:39 +00:00
|
|
|
|
|
|
|
console.log("Querying ...");
|
|
|
|
|
|
|
|
try {
|
|
|
|
const results = await MASTER.query(...args);
|
|
|
|
|
|
|
|
return JSON.parse(JSON.stringify(results));
|
2025-01-14 15:27:08 +00:00
|
|
|
} catch (error: any) {
|
2024-11-26 09:31:39 +00:00
|
|
|
console.log("DB Error =>", error.message);
|
|
|
|
return {
|
|
|
|
success: false,
|
|
|
|
error: error.message,
|
|
|
|
};
|
2025-01-14 15:27:08 +00:00
|
|
|
} finally {
|
|
|
|
await MASTER?.end();
|
2024-11-26 09:31:39 +00:00
|
|
|
}
|
|
|
|
}
|