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) =>
generateJoinStr(mtch, join)
)
.join(" AND ") +
.join(
join.operator
? ` ${join.operator} `
: " AND "
) +
")"
);
} else if (typeof join.match == "object") {

View File

@ -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<T extends object = {
[key: string]: any;
}> = {
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<ServerQueryObject<T>, "__query">;
@ -963,6 +965,7 @@ export type ServerQueryParamsJoin<Table extends string = string, Field extends o
alias?: string;
count?: boolean;
})[];
operator?: (typeof ServerQueryOperators)[number];
};
export type ServerQueryParamsJoinMatchObject<Field extends object = {
[key: string]: any;

View File

@ -1086,6 +1086,9 @@ export type FetchApiReturn = {
[key: string]: any;
};
export const ServerQueryOperators = ["AND", "OR"] as const;
export const ServerQueryEqualities = ["EQUAL", "LIKE", "NOT EQUAL"] as const;
export type ServerQueryParam = {
selectFields?: string[];
query?: ServerQueryQueryObject;
@ -1095,8 +1098,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;
};
@ -1106,8 +1109,8 @@ export type ServerQueryParam = {
export type ServerQueryObject<T extends object = { [key: string]: any }> = {
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<ServerQueryObject<T>, "__query">;
@ -1149,6 +1152,7 @@ export type ServerQueryParamsJoin<
count?: boolean;
}
)[];
operator?: (typeof ServerQueryOperators)[number];
};
export type ServerQueryParamsJoinMatchObject<

View File

@ -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": {