This commit is contained in:
Benjamin Toby 2024-11-12 06:47:31 +01:00
parent 7dd8111b5b
commit c6964df00b
2 changed files with 21 additions and 9 deletions

View File

@ -69,13 +69,22 @@ function sqlGenerator({ tableName, genObject }) {
typeof mtch.source == "object" ? mtch.source.tableName : tableName typeof mtch.source == "object" ? mtch.source.tableName : tableName
}.${ }.${
typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source
}=${ }=${(() => {
if (mtch.targetLiteral) {
sqlSearhValues.push(mtch.targetLiteral);
return "?";
}
return `${
typeof mtch.target == "object" typeof mtch.target == "object"
? mtch.target.tableName ? mtch.target.tableName
: join.tableName : join.tableName
}.${ }.${
typeof mtch.target == "object" ? mtch.target.fieldName : mtch.target typeof mtch.target == "object"
? mtch.target.fieldName
: mtch.target
}`; }`;
})()}`;
} }
let queryString = (() => { let queryString = (() => {

View File

@ -1168,6 +1168,7 @@ export type FetchDataParams = {
method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE"; method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
body?: object | string; body?: object | string;
query?: AuthFetchQuery; query?: AuthFetchQuery;
tableName?: string;
}; };
export type AuthFetchQuery = ServerQueryParam & { export type AuthFetchQuery = ServerQueryParam & {
@ -1196,9 +1197,11 @@ export type ServerQueryParamsJoinMatchObject<
Field extends object = { [key: string]: any } Field extends object = { [key: string]: any }
> = { > = {
/** Field name from the **Root Table** */ /** Field name from the **Root Table** */
source: string | ServerQueryParamsJoinMatchSourceTargetObject; source?: string | ServerQueryParamsJoinMatchSourceTargetObject;
/** Field name from the **Join Table** */ /** Field name from the **Join Table** */
target: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject; target?: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject;
/** A literal value: No source and target Needed! */
targetLiteral?: string;
}; };
export type ServerQueryParamsJoinMatchSourceTargetObject = { export type ServerQueryParamsJoinMatchSourceTargetObject = {