This commit is contained in:
Benjamin Toby
2025-01-15 21:51:05 +01:00
parent 785b15aad5
commit e13a14ab5c
12 changed files with 83 additions and 12 deletions
+11
View File
@@ -12,6 +12,7 @@ type Param = {
tableName?: string;
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
useLocal?: boolean;
debug?: boolean;
};
/**
@@ -24,6 +25,7 @@ export default async function apiGet({
tableName,
dbSchema,
useLocal,
debug,
}: Param): Promise<import("../../../types").GetReturn> {
if (
typeof query == "string" &&
@@ -45,6 +47,11 @@ export default async function apiGet({
local: useLocal,
});
if (debug) {
console.log("apiGet:result", result);
console.log("apiGet:error", error);
}
let tableSchema: DSQL_TableSchemaType | undefined;
if (dbSchema) {
@@ -83,6 +90,10 @@ export default async function apiGet({
message: error.message,
});
if (debug) {
console.log("apiGet:error", error.message);
}
return {
success: false,
payload: null,
@@ -12,6 +12,7 @@ type Param = {
query: string | any;
readOnly?: boolean;
local?: boolean;
debug?: boolean;
dbSchema?: import("../../../types").DSQL_DatabaseSchemaType;
queryValuesArray?: (string | number)[];
tableName?: string;
@@ -28,6 +29,7 @@ export default async function runQuery({
queryValuesArray,
tableName,
local,
debug,
}: Param): Promise<any> {
/**
* Declare variables
@@ -66,6 +68,10 @@ export default async function runQuery({
if (typeof query === "string") {
const formattedQuery = trimSql(query);
if (debug) {
console.log("runQuery:formattedQuery", formattedQuery);
}
/**
* Input Validation
*
@@ -167,11 +173,16 @@ export default async function runQuery({
break;
}
}
} catch (/** @type {any} */ error: any) {
} catch (error: any) {
serverError({
component: "functions/backend/runQuery",
message: error.message,
});
if (debug) {
console.log("runQuery:error", error.message);
}
result = null;
error = error.message;
}