import dbHandler from "./dbHandler"; import { DSQL_TableSchemaType } from "../../types"; type Param = { queryString: string; queryValuesArray?: string[]; database?: string; tableSchema?: DSQL_TableSchemaType; }; /** * # DB handler for specific database */ export default async function varDatabaseDbHandler({ queryString, queryValuesArray, database, tableSchema, }: Param): Promise { /** * Declare variables * * @description Declare "results" variable */ let results; /** * Fetch from db * * @description Fetch data from db if no cache */ try { if ( queryString && queryValuesArray && Array.isArray(queryValuesArray) && queryValuesArray[0] ) { results = await dbHandler({ query: queryString, values: queryValuesArray, database, }); } else { results = await dbHandler({ query: queryString, database, }); } //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } catch (/** @type {any} */ error: any) { console.log("Shell Vardb Error =>", error.message); } /** * Return results * * @description Return results add to cache if "req" param is passed */ return results; }