This commit is contained in:
Benjamin Toby 2026-03-08 14:29:33 +01:00
parent 835458cc14
commit 42ee8eaaa1
6 changed files with 28 additions and 26 deletions

View File

@ -475,10 +475,6 @@ export type ServerQueryParamsCount = {
}[]; }[];
alias: string; alias: string;
}; };
export type ServerQueryParamsCountSrcTrgMap = {
table: string;
field: string;
};
export type TableSelectFieldsObject<T extends { export type TableSelectFieldsObject<T extends {
[k: string]: any; [k: string]: any;
} = { } = {
@ -524,6 +520,10 @@ export type ServerQueryQueryObject<T extends object = {
}, K extends string = string> = { }, K extends string = string> = {
[key in keyof T]: ServerQueryObject<T, K>; [key in keyof T]: ServerQueryObject<T, K>;
}; };
export type ServerQueryParamsCountSrcTrgMap = {
table: string;
field: string;
};
export type FetchDataParams = { export type FetchDataParams = {
path: string; path: string;
method?: (typeof DataCrudRequestMethods)[number]; method?: (typeof DataCrudRequestMethods)[number];

View File

@ -1,4 +1,4 @@
import type { ServerQueryParam } from "../types"; import { ServerQueryParam } from "../types";
type Param<T extends { type Param<T extends {
[key: string]: any; [key: string]: any;
} = { } = {

View File

@ -106,6 +106,8 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
btch_mtch += `(`; btch_mtch += `(`;
for (let i = 0; i < mtch.__batch.matches.length; i++) { for (let i = 0; i < mtch.__batch.matches.length; i++) {
const __mtch = mtch.__batch.matches[i]; const __mtch = mtch.__batch.matches[i];
if (!__mtch)
continue;
btch_mtch += `${generateJoinStr(__mtch, join)}`; btch_mtch += `${generateJoinStr(__mtch, join)}`;
if (i < mtch.__batch.matches.length - 1) { if (i < mtch.__batch.matches.length - 1) {
btch_mtch += ` ${mtch.__batch.operator || "OR"} `; btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
@ -373,11 +375,11 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
if (Array.isArray(genObject.order)) { if (Array.isArray(genObject.order)) {
for (let i = 0; i < genObject.order.length; i++) { for (let i = 0; i < genObject.order.length; i++) {
const order = genObject.order[i]; const order = genObject.order[i];
if (order) { if (!order)
orderSrt += continue;
grabOrderString(order) + orderSrt +=
(i < genObject.order.length - 1 ? `,` : ""); grabOrderString(order) +
} (i < genObject.order.length - 1 ? `,` : "");
} }
} }
else { else {

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/nsqlite", "name": "@moduletrace/nsqlite",
"version": "1.0.8", "version": "1.0.9",
"description": "SQLite manager for Node JS", "description": "SQLite manager for Node JS",
"author": "Benjamin Toby", "author": "Benjamin Toby",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -542,11 +542,6 @@ export type ServerQueryParamsCount = {
alias: string; alias: string;
}; };
export type ServerQueryParamsCountSrcTrgMap = {
table: string;
field: string;
};
export type TableSelectFieldsObject< export type TableSelectFieldsObject<
T extends { [k: string]: any } = { [k: string]: any }, T extends { [k: string]: any } = { [k: string]: any },
> = { > = {
@ -600,6 +595,11 @@ export type ServerQueryQueryObject<
[key in keyof T]: ServerQueryObject<T, K>; [key in keyof T]: ServerQueryObject<T, K>;
}; };
export type ServerQueryParamsCountSrcTrgMap = {
table: string;
field: string;
};
export type FetchDataParams = { export type FetchDataParams = {
path: string; path: string;
method?: (typeof DataCrudRequestMethods)[number]; method?: (typeof DataCrudRequestMethods)[number];

View File

@ -1,6 +1,5 @@
import { isUndefined } from "lodash"; import { isUndefined } from "lodash";
import sqlGenOperatorGen from "./sql-gen-operator-gen"; import {
import type {
ServerQueryParam, ServerQueryParam,
ServerQueryParamOrder, ServerQueryParamOrder,
ServerQueryParamsJoin, ServerQueryParamsJoin,
@ -8,6 +7,7 @@ import type {
ServerQueryQueryObject, ServerQueryQueryObject,
ServerQueryValuesObject, ServerQueryValuesObject,
} from "../types"; } from "../types";
import sqlGenOperatorGen from "./sql-gen-operator-gen";
type Param<T extends { [key: string]: any } = { [key: string]: any }> = { type Param<T extends { [key: string]: any } = { [key: string]: any }> = {
genObject?: ServerQueryParam<T>; genObject?: ServerQueryParam<T>;
@ -151,9 +151,8 @@ export default function sqlGenerator<
btch_mtch += `(`; btch_mtch += `(`;
for (let i = 0; i < mtch.__batch.matches.length; i++) { for (let i = 0; i < mtch.__batch.matches.length; i++) {
const __mtch = mtch.__batch.matches[ const __mtch = mtch.__batch.matches[i];
i if (!__mtch) continue;
] as ServerQueryParamsJoinMatchObject;
btch_mtch += `${generateJoinStr(__mtch, join)}`; btch_mtch += `${generateJoinStr(__mtch, join)}`;
if (i < mtch.__batch.matches.length - 1) { if (i < mtch.__batch.matches.length - 1) {
btch_mtch += ` ${mtch.__batch.operator || "OR"} `; btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
@ -254,6 +253,7 @@ export default function sqlGenerator<
for (let i = 0; i < genObject.countSubQueries.length; i++) { for (let i = 0; i < genObject.countSubQueries.length; i++) {
const countSubQuery = genObject.countSubQueries[i]; const countSubQuery = genObject.countSubQueries[i];
if (!countSubQuery) continue; if (!countSubQuery) continue;
const tableAlias = countSubQuery.table_alias; const tableAlias = countSubQuery.table_alias;
@ -268,6 +268,7 @@ export default function sqlGenerator<
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) { for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
const csqSrc = countSubQuery.srcTrgMap[j]; const csqSrc = countSubQuery.srcTrgMap[j];
if (!csqSrc) continue; if (!csqSrc) continue;
subQStr += ` ${tableAlias || countSubQuery.table}.${ subQStr += ` ${tableAlias || countSubQuery.table}.${
@ -497,11 +498,10 @@ export default function sqlGenerator<
if (Array.isArray(genObject.order)) { if (Array.isArray(genObject.order)) {
for (let i = 0; i < genObject.order.length; i++) { for (let i = 0; i < genObject.order.length; i++) {
const order = genObject.order[i]; const order = genObject.order[i];
if (order) { if (!order) continue;
orderSrt += orderSrt +=
grabOrderString(order) + grabOrderString(order) +
(i < genObject.order.length - 1 ? `,` : ""); (i < genObject.order.length - 1 ? `,` : "");
}
} }
} else { } else {
orderSrt += grabOrderString(genObject.order); orderSrt += grabOrderString(genObject.order);