This commit is contained in:
Benjamin Toby 2024-12-28 18:44:08 +01:00
parent 29fd6e6203
commit 92290f3796
4 changed files with 21 additions and 10 deletions

View File

@ -214,7 +214,11 @@ function sqlGenerator({ tableName, genObject }) {
.map((mtch) => .map((mtch) =>
generateJoinStr(mtch, join) generateJoinStr(mtch, join)
) )
.join(" AND ") + .join(
join.operator
? ` ${join.operator} `
: " AND "
) +
")" ")"
); );
} else if (typeof join.match == "object") { } else if (typeof join.match == "object") {

View File

@ -908,6 +908,8 @@ export type FetchApiReturn = {
msg?: string; msg?: string;
[key: string]: any; [key: string]: any;
}; };
export declare const ServerQueryOperators: readonly ["AND", "OR"];
export declare const ServerQueryEqualities: readonly ["EQUAL", "LIKE", "NOT EQUAL"];
export type ServerQueryParam = { export type ServerQueryParam = {
selectFields?: string[]; selectFields?: string[];
query?: ServerQueryQueryObject; query?: ServerQueryQueryObject;
@ -917,8 +919,8 @@ export type ServerQueryParam = {
field: string; field: string;
strategy: "ASC" | "DESC"; strategy: "ASC" | "DESC";
}; };
searchOperator?: "AND" | "OR"; searchOperator?: (typeof ServerQueryOperators)[number];
searchEquality?: "EQUAL" | "LIKE" | "NOT EQUAL"; searchEquality?: (typeof ServerQueryEqualities)[number];
addUserId?: { addUserId?: {
fieldName: string; fieldName: string;
}; };
@ -929,8 +931,8 @@ export type ServerQueryObject<T extends object = {
[key: string]: any; [key: string]: any;
}> = { }> = {
value?: string | string[]; value?: string | string[];
operator?: "AND" | "OR"; operator?: (typeof ServerQueryOperators)[number];
equality?: "EQUAL" | "LIKE" | "NOT EQUAL"; equality?: (typeof ServerQueryEqualities)[number];
tableName?: string; tableName?: string;
__query?: { __query?: {
[key in keyof T]: Omit<ServerQueryObject<T>, "__query">; [key in keyof T]: Omit<ServerQueryObject<T>, "__query">;
@ -963,6 +965,7 @@ export type ServerQueryParamsJoin<Table extends string = string, Field extends o
alias?: string; alias?: string;
count?: boolean; count?: boolean;
})[]; })[];
operator?: (typeof ServerQueryOperators)[number];
}; };
export type ServerQueryParamsJoinMatchObject<Field extends object = { export type ServerQueryParamsJoinMatchObject<Field extends object = {
[key: string]: any; [key: string]: any;

View File

@ -1086,6 +1086,9 @@ export type FetchApiReturn = {
[key: string]: any; [key: string]: any;
}; };
export const ServerQueryOperators = ["AND", "OR"] as const;
export const ServerQueryEqualities = ["EQUAL", "LIKE", "NOT EQUAL"] as const;
export type ServerQueryParam = { export type ServerQueryParam = {
selectFields?: string[]; selectFields?: string[];
query?: ServerQueryQueryObject; query?: ServerQueryQueryObject;
@ -1095,8 +1098,8 @@ export type ServerQueryParam = {
field: string; field: string;
strategy: "ASC" | "DESC"; strategy: "ASC" | "DESC";
}; };
searchOperator?: "AND" | "OR"; searchOperator?: (typeof ServerQueryOperators)[number];
searchEquality?: "EQUAL" | "LIKE" | "NOT EQUAL"; searchEquality?: (typeof ServerQueryEqualities)[number];
addUserId?: { addUserId?: {
fieldName: string; fieldName: string;
}; };
@ -1106,8 +1109,8 @@ export type ServerQueryParam = {
export type ServerQueryObject<T extends object = { [key: string]: any }> = { export type ServerQueryObject<T extends object = { [key: string]: any }> = {
value?: string | string[]; value?: string | string[];
operator?: "AND" | "OR"; operator?: (typeof ServerQueryOperators)[number];
equality?: "EQUAL" | "LIKE" | "NOT EQUAL"; equality?: (typeof ServerQueryEqualities)[number];
tableName?: string; tableName?: string;
__query?: { __query?: {
[key in keyof T]: Omit<ServerQueryObject<T>, "__query">; [key in keyof T]: Omit<ServerQueryObject<T>, "__query">;
@ -1149,6 +1152,7 @@ export type ServerQueryParamsJoin<
count?: boolean; count?: boolean;
} }
)[]; )[];
operator?: (typeof ServerQueryOperators)[number];
}; };
export type ServerQueryParamsJoinMatchObject< export type ServerQueryParamsJoinMatchObject<

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "3.2.6", "version": "3.2.7",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"bin": { "bin": {