diff --git a/package-shared/functions/dsql/sql/sql-generator.js b/package-shared/functions/dsql/sql/sql-generator.js index 90d5747..3339764 100644 --- a/package-shared/functions/dsql/sql/sql-generator.js +++ b/package-shared/functions/dsql/sql/sql-generator.js @@ -214,7 +214,11 @@ function sqlGenerator({ tableName, genObject }) { .map((mtch) => generateJoinStr(mtch, join) ) - .join(" AND ") + + .join( + join.operator + ? ` ${join.operator} ` + : " AND " + ) + ")" ); } else if (typeof join.match == "object") { diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index 88d3dce..044afa0 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -908,6 +908,8 @@ export type FetchApiReturn = { msg?: string; [key: string]: any; }; +export declare const ServerQueryOperators: readonly ["AND", "OR"]; +export declare const ServerQueryEqualities: readonly ["EQUAL", "LIKE", "NOT EQUAL"]; export type ServerQueryParam = { selectFields?: string[]; query?: ServerQueryQueryObject; @@ -917,8 +919,8 @@ export type ServerQueryParam = { field: string; strategy: "ASC" | "DESC"; }; - searchOperator?: "AND" | "OR"; - searchEquality?: "EQUAL" | "LIKE" | "NOT EQUAL"; + searchOperator?: (typeof ServerQueryOperators)[number]; + searchEquality?: (typeof ServerQueryEqualities)[number]; addUserId?: { fieldName: string; }; @@ -929,8 +931,8 @@ export type ServerQueryObject = { value?: string | string[]; - operator?: "AND" | "OR"; - equality?: "EQUAL" | "LIKE" | "NOT EQUAL"; + operator?: (typeof ServerQueryOperators)[number]; + equality?: (typeof ServerQueryEqualities)[number]; tableName?: string; __query?: { [key in keyof T]: Omit, "__query">; @@ -963,6 +965,7 @@ export type ServerQueryParamsJoin = { value?: string | string[]; - operator?: "AND" | "OR"; - equality?: "EQUAL" | "LIKE" | "NOT EQUAL"; + operator?: (typeof ServerQueryOperators)[number]; + equality?: (typeof ServerQueryEqualities)[number]; tableName?: string; __query?: { [key in keyof T]: Omit, "__query">; @@ -1149,6 +1152,7 @@ export type ServerQueryParamsJoin< count?: boolean; } )[]; + operator?: (typeof ServerQueryOperators)[number]; }; export type ServerQueryParamsJoinMatchObject< diff --git a/package.json b/package.json index a25f79f..92e14ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "3.2.6", + "version": "3.2.7", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": {