dsql-admin/dsql-app/package-shared/utils/backend/global-db/DSQL_USER_DB_HANDLER.ts
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

32 lines
798 B
TypeScript

import connDbHandler from "../../db/conn-db-handler";
import grabDSQLConnection from "../../grab-dsql-connection";
type Param = {
paradigm: "Full Access" | "FA" | "Read Only";
queryString: string;
queryValues?: string[];
};
/**
* # DSQL user read-only DB handler
*/
export default async function DSQL_USER_DB_HANDLER({
paradigm,
queryString,
queryValues,
}: Param) {
const CONNECTION =
paradigm == "Read Only"
? grabDSQLConnection({ ro: true })
: grabDSQLConnection({ fa: true });
try {
return await connDbHandler(CONNECTION, queryString, queryValues);
} catch (error: any) {
console.log(`DSQL_USER_DB_HANDLER Error: ${error.message}`);
return null;
} finally {
CONNECTION?.end();
}
}