Updates
This commit is contained in:
parent
835458cc14
commit
42ee8eaaa1
8
dist/types/index.d.ts
vendored
8
dist/types/index.d.ts
vendored
@ -475,10 +475,6 @@ export type ServerQueryParamsCount = {
|
||||
}[];
|
||||
alias: string;
|
||||
};
|
||||
export type ServerQueryParamsCountSrcTrgMap = {
|
||||
table: string;
|
||||
field: string;
|
||||
};
|
||||
export type TableSelectFieldsObject<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
@ -524,6 +520,10 @@ export type ServerQueryQueryObject<T extends object = {
|
||||
}, K extends string = string> = {
|
||||
[key in keyof T]: ServerQueryObject<T, K>;
|
||||
};
|
||||
export type ServerQueryParamsCountSrcTrgMap = {
|
||||
table: string;
|
||||
field: string;
|
||||
};
|
||||
export type FetchDataParams = {
|
||||
path: string;
|
||||
method?: (typeof DataCrudRequestMethods)[number];
|
||||
|
||||
2
dist/utils/sql-generator.d.ts
vendored
2
dist/utils/sql-generator.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import type { ServerQueryParam } from "../types";
|
||||
import { ServerQueryParam } from "../types";
|
||||
type Param<T extends {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
|
||||
12
dist/utils/sql-generator.js
vendored
12
dist/utils/sql-generator.js
vendored
@ -106,6 +106,8 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
btch_mtch += `(`;
|
||||
for (let i = 0; i < mtch.__batch.matches.length; i++) {
|
||||
const __mtch = mtch.__batch.matches[i];
|
||||
if (!__mtch)
|
||||
continue;
|
||||
btch_mtch += `${generateJoinStr(__mtch, join)}`;
|
||||
if (i < mtch.__batch.matches.length - 1) {
|
||||
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
|
||||
@ -373,11 +375,11 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
if (Array.isArray(genObject.order)) {
|
||||
for (let i = 0; i < genObject.order.length; i++) {
|
||||
const order = genObject.order[i];
|
||||
if (order) {
|
||||
orderSrt +=
|
||||
grabOrderString(order) +
|
||||
(i < genObject.order.length - 1 ? `,` : "");
|
||||
}
|
||||
if (!order)
|
||||
continue;
|
||||
orderSrt +=
|
||||
grabOrderString(order) +
|
||||
(i < genObject.order.length - 1 ? `,` : "");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/nsqlite",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "SQLite manager for Node JS",
|
||||
"author": "Benjamin Toby",
|
||||
"main": "dist/index.js",
|
||||
|
||||
@ -542,11 +542,6 @@ export type ServerQueryParamsCount = {
|
||||
alias: string;
|
||||
};
|
||||
|
||||
export type ServerQueryParamsCountSrcTrgMap = {
|
||||
table: string;
|
||||
field: string;
|
||||
};
|
||||
|
||||
export type TableSelectFieldsObject<
|
||||
T extends { [k: string]: any } = { [k: string]: any },
|
||||
> = {
|
||||
@ -600,6 +595,11 @@ export type ServerQueryQueryObject<
|
||||
[key in keyof T]: ServerQueryObject<T, K>;
|
||||
};
|
||||
|
||||
export type ServerQueryParamsCountSrcTrgMap = {
|
||||
table: string;
|
||||
field: string;
|
||||
};
|
||||
|
||||
export type FetchDataParams = {
|
||||
path: string;
|
||||
method?: (typeof DataCrudRequestMethods)[number];
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { isUndefined } from "lodash";
|
||||
import sqlGenOperatorGen from "./sql-gen-operator-gen";
|
||||
import type {
|
||||
import {
|
||||
ServerQueryParam,
|
||||
ServerQueryParamOrder,
|
||||
ServerQueryParamsJoin,
|
||||
@ -8,6 +7,7 @@ import type {
|
||||
ServerQueryQueryObject,
|
||||
ServerQueryValuesObject,
|
||||
} from "../types";
|
||||
import sqlGenOperatorGen from "./sql-gen-operator-gen";
|
||||
|
||||
type Param<T extends { [key: string]: any } = { [key: string]: any }> = {
|
||||
genObject?: ServerQueryParam<T>;
|
||||
@ -151,9 +151,8 @@ export default function sqlGenerator<
|
||||
btch_mtch += `(`;
|
||||
|
||||
for (let i = 0; i < mtch.__batch.matches.length; i++) {
|
||||
const __mtch = mtch.__batch.matches[
|
||||
i
|
||||
] as ServerQueryParamsJoinMatchObject;
|
||||
const __mtch = mtch.__batch.matches[i];
|
||||
if (!__mtch) continue;
|
||||
btch_mtch += `${generateJoinStr(__mtch, join)}`;
|
||||
if (i < mtch.__batch.matches.length - 1) {
|
||||
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
|
||||
@ -254,6 +253,7 @@ export default function sqlGenerator<
|
||||
|
||||
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
||||
const countSubQuery = genObject.countSubQueries[i];
|
||||
|
||||
if (!countSubQuery) continue;
|
||||
|
||||
const tableAlias = countSubQuery.table_alias;
|
||||
@ -268,6 +268,7 @@ export default function sqlGenerator<
|
||||
|
||||
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
||||
const csqSrc = countSubQuery.srcTrgMap[j];
|
||||
|
||||
if (!csqSrc) continue;
|
||||
|
||||
subQStr += ` ${tableAlias || countSubQuery.table}.${
|
||||
@ -497,11 +498,10 @@ export default function sqlGenerator<
|
||||
if (Array.isArray(genObject.order)) {
|
||||
for (let i = 0; i < genObject.order.length; i++) {
|
||||
const order = genObject.order[i];
|
||||
if (order) {
|
||||
orderSrt +=
|
||||
grabOrderString(order) +
|
||||
(i < genObject.order.length - 1 ? `,` : "");
|
||||
}
|
||||
if (!order) continue;
|
||||
orderSrt +=
|
||||
grabOrderString(order) +
|
||||
(i < genObject.order.length - 1 ? `,` : "");
|
||||
}
|
||||
} else {
|
||||
orderSrt += grabOrderString(genObject.order);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user