import grabDSQLConnection from "../../grab-dsql-connection";

/**
 * # DSQL user read-only DB handler
 */
export default async function LOCAL_DB_HANDLER(...args: any[]) {
    const MASTER = grabDSQLConnection();

    try {
        const results = await MASTER.query(...args);

        return JSON.parse(JSON.stringify(results));
    } catch (error: any) {
        console.log("DB Error =>", error.message);
        return {
            success: false,
            error: error.message,
        };
    } finally {
        await MASTER?.end();
    }
}
