Updates
This commit is contained in:
parent
0858b18344
commit
7959014721
@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = addDbEntry;
|
||||
const sql_formatter_1 = require("sql-formatter");
|
||||
const updateDbEntry_1 = __importDefault(require("./updateDbEntry"));
|
||||
const lodash_1 = __importDefault(require("lodash"));
|
||||
const conn_db_handler_1 = __importDefault(require("../../../utils/db/conn-db-handler"));
|
||||
@ -191,7 +192,7 @@ function addDbEntry(_a) {
|
||||
success: Boolean(newInsert === null || newInsert === void 0 ? void 0 : newInsert.insertId),
|
||||
payload: newInsert,
|
||||
queryObject: {
|
||||
sql: query,
|
||||
sql: (0, sql_formatter_1.format)(query),
|
||||
params: finalQueryValues,
|
||||
},
|
||||
};
|
||||
|
||||
@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = updateDbEntry;
|
||||
const sql_formatter_1 = require("sql-formatter");
|
||||
const check_if_is_master_1 = __importDefault(require("../../../utils/check-if-is-master"));
|
||||
const conn_db_handler_1 = __importDefault(require("../../../utils/db/conn-db-handler"));
|
||||
const lodash_1 = __importDefault(require("lodash"));
|
||||
@ -109,7 +110,7 @@ function updateDbEntry(_a) {
|
||||
success: Boolean(updatedEntry === null || updatedEntry === void 0 ? void 0 : updatedEntry.affectedRows),
|
||||
payload: updatedEntry,
|
||||
queryObject: {
|
||||
sql: query,
|
||||
sql: (0, sql_formatter_1.format)(query),
|
||||
params: updateValues,
|
||||
},
|
||||
debug: debug ? { data, newData } : undefined,
|
||||
|
||||
@ -77,55 +77,9 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
else if (operatorStrParam.str) {
|
||||
str = operatorStrParam.str;
|
||||
}
|
||||
// if (queryObj.equality == "LIKE") {
|
||||
// str = `LOWER(${finalFieldName}) LIKE LOWER('%${valueParsed}%')`;
|
||||
// } else if (queryObj.equality == "LIKE_RAW") {
|
||||
// str = `LOWER(${finalFieldName}) LIKE LOWER(?)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "NOT LIKE") {
|
||||
// str = `LOWER(${finalFieldName}) NOT LIKE LOWER('%${valueParsed}%')`;
|
||||
// } else if (queryObj.equality == "NOT LIKE_RAW") {
|
||||
// str = `LOWER(${finalFieldName}) NOT LIKE LOWER(?)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "REGEXP") {
|
||||
// str = `LOWER(${finalFieldName}) REGEXP LOWER(?)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "FULLTEXT") {
|
||||
// str = `MATCH(${finalFieldName}) AGAINST(? IN BOOLEAN MODE)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "NOT EQUAL") {
|
||||
// str = `${finalFieldName} != ?`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality) {
|
||||
// str = `${finalFieldName} ${operator} ?`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else {
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// }
|
||||
}
|
||||
return str;
|
||||
}
|
||||
const sqlSearhString = queryKeys === null || queryKeys === void 0 ? void 0 : queryKeys.map((field) => {
|
||||
const queryObj = finalQuery === null || finalQuery === void 0 ? void 0 : finalQuery[field];
|
||||
if (!queryObj)
|
||||
return;
|
||||
if (queryObj.__query) {
|
||||
const subQueryGroup = queryObj.__query;
|
||||
const subSearchKeys = Object.keys(subQueryGroup);
|
||||
const subSearchString = subSearchKeys.map((_field) => {
|
||||
const newSubQueryObj = subQueryGroup === null || subQueryGroup === void 0 ? void 0 : subQueryGroup[_field];
|
||||
return genSqlSrchStr({
|
||||
queryObj: newSubQueryObj,
|
||||
field: _field,
|
||||
join: genObject === null || genObject === void 0 ? void 0 : genObject.join,
|
||||
});
|
||||
});
|
||||
return ("(" +
|
||||
subSearchString.join(` ${queryObj.operator || "AND"} `) +
|
||||
")");
|
||||
}
|
||||
return genSqlSrchStr({ queryObj, field, join: genObject === null || genObject === void 0 ? void 0 : genObject.join });
|
||||
});
|
||||
function generateJoinStr(mtch, join) {
|
||||
return `${finalDbName}${typeof mtch.source == "object" ? mtch.source.tableName : tableName}.${typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source}=${(() => {
|
||||
if (mtch.targetLiteral) {
|
||||
@ -173,6 +127,32 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
str += " *";
|
||||
}
|
||||
}
|
||||
if (genObject === null || genObject === void 0 ? void 0 : genObject.countSubQueries) {
|
||||
let countSqls = [];
|
||||
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
||||
const countSubQuery = genObject.countSubQueries[i];
|
||||
let subQStr = `(SELECT COUNT(*)`;
|
||||
subQStr += ` FROM ${countSubQuery.table}`;
|
||||
subQStr += ` WHERE (`;
|
||||
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
||||
const csqSrc = countSubQuery.srcTrgMap[j];
|
||||
subQStr += ` ${countSubQuery.table}.${csqSrc.src}`;
|
||||
if (typeof csqSrc.trg == "string") {
|
||||
subQStr += ` = ?`;
|
||||
sqlSearhValues.push(csqSrc.trg);
|
||||
}
|
||||
else if (typeof csqSrc.trg == "object") {
|
||||
subQStr += ` = ${csqSrc.trg.table}.${csqSrc.trg.field}`;
|
||||
}
|
||||
if (j < countSubQuery.srcTrgMap.length - 1) {
|
||||
subQStr += ` AND `;
|
||||
}
|
||||
}
|
||||
subQStr += ` )) AS ${countSubQuery.alias}`;
|
||||
countSqls.push(subQStr);
|
||||
}
|
||||
str += `, ${countSqls.join(",")}`;
|
||||
}
|
||||
if ((genObject === null || genObject === void 0 ? void 0 : genObject.join) && !count) {
|
||||
const existingJoinTableNames = [tableName];
|
||||
str +=
|
||||
@ -242,6 +222,27 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
}
|
||||
return str;
|
||||
})();
|
||||
const sqlSearhString = queryKeys === null || queryKeys === void 0 ? void 0 : queryKeys.map((field) => {
|
||||
const queryObj = finalQuery === null || finalQuery === void 0 ? void 0 : finalQuery[field];
|
||||
if (!queryObj)
|
||||
return;
|
||||
if (queryObj.__query) {
|
||||
const subQueryGroup = queryObj.__query;
|
||||
const subSearchKeys = Object.keys(subQueryGroup);
|
||||
const subSearchString = subSearchKeys.map((_field) => {
|
||||
const newSubQueryObj = subQueryGroup === null || subQueryGroup === void 0 ? void 0 : subQueryGroup[_field];
|
||||
return genSqlSrchStr({
|
||||
queryObj: newSubQueryObj,
|
||||
field: _field,
|
||||
join: genObject === null || genObject === void 0 ? void 0 : genObject.join,
|
||||
});
|
||||
});
|
||||
return ("(" +
|
||||
subSearchString.join(` ${queryObj.operator || "AND"} `) +
|
||||
")");
|
||||
}
|
||||
return genSqlSrchStr({ queryObj, field, join: genObject === null || genObject === void 0 ? void 0 : genObject.join });
|
||||
});
|
||||
if ((sqlSearhString === null || sqlSearhString === void 0 ? void 0 : sqlSearhString[0]) && sqlSearhString.find((str) => str)) {
|
||||
const stringOperator = (genObject === null || genObject === void 0 ? void 0 : genObject.searchOperator) || "AND";
|
||||
queryString += ` WHERE ${sqlSearhString.join(` ${stringOperator} `)}`;
|
||||
|
||||
15
dist/package-shared/types/index.d.ts
vendored
15
dist/package-shared/types/index.d.ts
vendored
@ -827,8 +827,21 @@ export type ServerQueryParam<T extends {
|
||||
};
|
||||
join?: ServerQueryParamsJoin<K>[];
|
||||
group?: (keyof T)[];
|
||||
countSubQueries?: ServerQueryParamsCount[];
|
||||
[key: string]: any;
|
||||
};
|
||||
export type ServerQueryParamsCount = {
|
||||
table: string;
|
||||
srcTrgMap: {
|
||||
src: string;
|
||||
trg: string | ServerQueryParamsCountSrcTrgMap;
|
||||
}[];
|
||||
alias: string;
|
||||
};
|
||||
export type ServerQueryParamsCountSrcTrgMap = {
|
||||
table: string;
|
||||
field: string;
|
||||
};
|
||||
export type TableSelectFieldsObject<T extends {
|
||||
[k: string]: any;
|
||||
} = {
|
||||
@ -1543,8 +1556,8 @@ export type MediaUploadDataType = ImageObjectType & FileObjectType & {
|
||||
existingMediaRecordId?: number;
|
||||
};
|
||||
export declare const ImageMimeTypes: (keyof sharp.FormatEnum)[];
|
||||
export declare const FileMimeTypes: readonly ["pdf", "csv", "json", "sql", "xlsx", "txt", "zip", "tar.xz", "xz", "yaml", "yml", "sh", "jsx", "js", "tsx", "ts", "html", "css"];
|
||||
export declare const VideoMimeTypes: readonly ["mp4", "wav"];
|
||||
export declare const FileMimeTypes: readonly [...(keyof sharp.FormatEnum)[], "mp4", "wav", "pdf", "csv", "json", "sql", "xlsx", "txt", "zip", "tar.xz", "xz", "yaml", "yml", "sh", "jsx", "js", "tsx", "ts", "html", "css"];
|
||||
export declare const CurrentlyEditedFieldActions: readonly ["edit-field", "edit-index", "delete-field", "delete-index", "new-field", "new-index", "move-up", "move-down", "complete"];
|
||||
export type CurrentlyEditedTableSchemaType = {
|
||||
action: (typeof CurrentlyEditedFieldActions)[number];
|
||||
|
||||
6
dist/package-shared/types/index.js
vendored
6
dist/package-shared/types/index.js
vendored
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AIOptions = exports.OpsActions = exports.TimeParadigms = exports.UserAPIAuthActions = exports.UserAPIParadigms = exports.TargetMediaParadigms = exports.EnvKeys = exports.AppVersions = exports.APIParadigms = exports.UserSQLPermissions = exports.SQLPermissions = exports.InvitedUserSelectFields = exports.DelegatedUserSelectFields = exports.UserSelectFields = exports.IndexTypes = exports.DefaultSQLValuesLiteral = exports.CurrentlyEditedFieldActions = exports.VideoMimeTypes = exports.FileMimeTypes = exports.ImageMimeTypes = exports.MediaTypes = exports.DockerComposeServices = exports.DatasquirelWindowEvents = exports.WebSocketEvents = exports.QueueJobTypes = exports.SignUpParadigms = exports.UserTypes = exports.QueryFields = exports.DsqlCrudActions = exports.DataCrudRequestMethodsLowerCase = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = exports.UsersOmitedFields = void 0;
|
||||
exports.AIOptions = exports.OpsActions = exports.TimeParadigms = exports.UserAPIAuthActions = exports.UserAPIParadigms = exports.TargetMediaParadigms = exports.EnvKeys = exports.AppVersions = exports.APIParadigms = exports.UserSQLPermissions = exports.SQLPermissions = exports.InvitedUserSelectFields = exports.DelegatedUserSelectFields = exports.UserSelectFields = exports.IndexTypes = exports.DefaultSQLValuesLiteral = exports.CurrentlyEditedFieldActions = exports.FileMimeTypes = exports.VideoMimeTypes = exports.ImageMimeTypes = exports.MediaTypes = exports.DockerComposeServices = exports.DatasquirelWindowEvents = exports.WebSocketEvents = exports.QueueJobTypes = exports.SignUpParadigms = exports.UserTypes = exports.QueryFields = exports.DsqlCrudActions = exports.DataCrudRequestMethodsLowerCase = exports.DataCrudRequestMethods = exports.ServerQueryEqualities = exports.ServerQueryOperators = exports.TextFieldTypesArray = exports.UsersOmitedFields = void 0;
|
||||
exports.UsersOmitedFields = [
|
||||
"password",
|
||||
"social_id",
|
||||
@ -146,7 +146,10 @@ exports.ImageMimeTypes = [
|
||||
"jpeg",
|
||||
"jpg",
|
||||
];
|
||||
exports.VideoMimeTypes = ["mp4", "wav"];
|
||||
exports.FileMimeTypes = [
|
||||
...exports.ImageMimeTypes,
|
||||
...exports.VideoMimeTypes,
|
||||
"pdf",
|
||||
"csv",
|
||||
"json",
|
||||
@ -166,7 +169,6 @@ exports.FileMimeTypes = [
|
||||
"html",
|
||||
"css",
|
||||
];
|
||||
exports.VideoMimeTypes = ["mp4", "wav"];
|
||||
exports.CurrentlyEditedFieldActions = [
|
||||
"edit-field",
|
||||
"edit-index",
|
||||
|
||||
@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const sql_formatter_1 = require("sql-formatter");
|
||||
const sql_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-generator"));
|
||||
const conn_db_handler_1 = __importDefault(require("../db/conn-db-handler"));
|
||||
const check_array_depth_1 = __importDefault(require("../check-array-depth"));
|
||||
@ -78,11 +79,11 @@ function default_1(_a) {
|
||||
: undefined,
|
||||
errors: res === null || res === void 0 ? void 0 : res.errors,
|
||||
queryObject: {
|
||||
sql: queryObject === null || queryObject === void 0 ? void 0 : queryObject.string,
|
||||
sql: (0, sql_formatter_1.format)((queryObject === null || queryObject === void 0 ? void 0 : queryObject.string) || "") || undefined,
|
||||
params: queryObject === null || queryObject === void 0 ? void 0 : queryObject.values,
|
||||
},
|
||||
countQueryObject: {
|
||||
sql: countQueryObject === null || countQueryObject === void 0 ? void 0 : countQueryObject.string,
|
||||
sql: (0, sql_formatter_1.format)((countQueryObject === null || countQueryObject === void 0 ? void 0 : countQueryObject.string) || "") || undefined,
|
||||
params: countQueryObject === null || countQueryObject === void 0 ? void 0 : countQueryObject.values,
|
||||
},
|
||||
count: isSuccess
|
||||
|
||||
@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = dsqlCrud;
|
||||
const sql_formatter_1 = require("sql-formatter");
|
||||
const sql_delete_generator_1 = __importDefault(require("../../functions/dsql/sql/sql-delete-generator"));
|
||||
const crud_get_1 = __importDefault(require("./crud-get"));
|
||||
const conn_db_handler_1 = __importDefault(require("../db/conn-db-handler"));
|
||||
@ -73,7 +74,7 @@ function dsqlCrud(params) {
|
||||
success: Boolean(res.affectedRows),
|
||||
payload: res,
|
||||
queryObject: {
|
||||
sql: (deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.query) || "",
|
||||
sql: (0, sql_formatter_1.format)((deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.query) || ""),
|
||||
params: (deleteQuery === null || deleteQuery === void 0 ? void 0 : deleteQuery.values) || [],
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { format } from "sql-formatter";
|
||||
import updateDbEntry from "./updateDbEntry";
|
||||
import _ from "lodash";
|
||||
import connDbHandler from "../../../utils/db/conn-db-handler";
|
||||
@ -276,7 +277,7 @@ export default async function addDbEntry<
|
||||
success: Boolean(newInsert?.insertId),
|
||||
payload: newInsert,
|
||||
queryObject: {
|
||||
sql: query,
|
||||
sql: format(query),
|
||||
params: finalQueryValues,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { format } from "sql-formatter";
|
||||
import checkIfIsMaster from "../../../utils/check-if-is-master";
|
||||
import connDbHandler from "../../../utils/db/conn-db-handler";
|
||||
import { DbContextsArray } from "./runQuery";
|
||||
@ -155,7 +156,7 @@ export default async function updateDbEntry<
|
||||
success: Boolean(updatedEntry?.affectedRows),
|
||||
payload: updatedEntry,
|
||||
queryObject: {
|
||||
sql: query,
|
||||
sql: format(query),
|
||||
params: updateValues,
|
||||
},
|
||||
debug: debug ? { data, newData } : undefined,
|
||||
|
||||
@ -110,65 +110,11 @@ export default function sqlGenerator<
|
||||
} else if (operatorStrParam.str) {
|
||||
str = operatorStrParam.str;
|
||||
}
|
||||
|
||||
// if (queryObj.equality == "LIKE") {
|
||||
// str = `LOWER(${finalFieldName}) LIKE LOWER('%${valueParsed}%')`;
|
||||
// } else if (queryObj.equality == "LIKE_RAW") {
|
||||
// str = `LOWER(${finalFieldName}) LIKE LOWER(?)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "NOT LIKE") {
|
||||
// str = `LOWER(${finalFieldName}) NOT LIKE LOWER('%${valueParsed}%')`;
|
||||
// } else if (queryObj.equality == "NOT LIKE_RAW") {
|
||||
// str = `LOWER(${finalFieldName}) NOT LIKE LOWER(?)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "REGEXP") {
|
||||
// str = `LOWER(${finalFieldName}) REGEXP LOWER(?)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "FULLTEXT") {
|
||||
// str = `MATCH(${finalFieldName}) AGAINST(? IN BOOLEAN MODE)`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality == "NOT EQUAL") {
|
||||
// str = `${finalFieldName} != ?`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else if (queryObj.equality) {
|
||||
// str = `${finalFieldName} ${operator} ?`;
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// } else {
|
||||
// sqlSearhValues.push(valueParsed);
|
||||
// }
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
const sqlSearhString = queryKeys?.map((field) => {
|
||||
const queryObj = finalQuery?.[field];
|
||||
if (!queryObj) return;
|
||||
|
||||
if (queryObj.__query) {
|
||||
const subQueryGroup = queryObj.__query;
|
||||
|
||||
const subSearchKeys = Object.keys(subQueryGroup);
|
||||
const subSearchString = subSearchKeys.map((_field) => {
|
||||
const newSubQueryObj = subQueryGroup?.[_field];
|
||||
|
||||
return genSqlSrchStr({
|
||||
queryObj: newSubQueryObj,
|
||||
field: _field,
|
||||
join: genObject?.join,
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
"(" +
|
||||
subSearchString.join(` ${queryObj.operator || "AND"} `) +
|
||||
")"
|
||||
);
|
||||
}
|
||||
|
||||
return genSqlSrchStr({ queryObj, field, join: genObject?.join });
|
||||
});
|
||||
|
||||
function generateJoinStr(
|
||||
mtch: ServerQueryParamsJoinMatchObject,
|
||||
join: ServerQueryParamsJoin
|
||||
@ -239,6 +185,38 @@ export default function sqlGenerator<
|
||||
}
|
||||
}
|
||||
|
||||
if (genObject?.countSubQueries) {
|
||||
let countSqls: string[] = [];
|
||||
|
||||
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
||||
const countSubQuery = genObject.countSubQueries[i];
|
||||
let subQStr = `(SELECT COUNT(*)`;
|
||||
subQStr += ` FROM ${countSubQuery.table}`;
|
||||
subQStr += ` WHERE (`;
|
||||
|
||||
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
||||
const csqSrc = countSubQuery.srcTrgMap[j];
|
||||
subQStr += ` ${countSubQuery.table}.${csqSrc.src}`;
|
||||
|
||||
if (typeof csqSrc.trg == "string") {
|
||||
subQStr += ` = ?`;
|
||||
sqlSearhValues.push(csqSrc.trg);
|
||||
} else if (typeof csqSrc.trg == "object") {
|
||||
subQStr += ` = ${csqSrc.trg.table}.${csqSrc.trg.field}`;
|
||||
}
|
||||
|
||||
if (j < countSubQuery.srcTrgMap.length - 1) {
|
||||
subQStr += ` AND `;
|
||||
}
|
||||
}
|
||||
|
||||
subQStr += ` )) AS ${countSubQuery.alias}`;
|
||||
countSqls.push(subQStr);
|
||||
}
|
||||
|
||||
str += `, ${countSqls.join(",")}`;
|
||||
}
|
||||
|
||||
if (genObject?.join && !count) {
|
||||
const existingJoinTableNames: string[] = [tableName];
|
||||
|
||||
@ -320,6 +298,34 @@ export default function sqlGenerator<
|
||||
return str;
|
||||
})();
|
||||
|
||||
const sqlSearhString = queryKeys?.map((field) => {
|
||||
const queryObj = finalQuery?.[field];
|
||||
if (!queryObj) return;
|
||||
|
||||
if (queryObj.__query) {
|
||||
const subQueryGroup = queryObj.__query;
|
||||
|
||||
const subSearchKeys = Object.keys(subQueryGroup);
|
||||
const subSearchString = subSearchKeys.map((_field) => {
|
||||
const newSubQueryObj = subQueryGroup?.[_field];
|
||||
|
||||
return genSqlSrchStr({
|
||||
queryObj: newSubQueryObj,
|
||||
field: _field,
|
||||
join: genObject?.join,
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
"(" +
|
||||
subSearchString.join(` ${queryObj.operator || "AND"} `) +
|
||||
")"
|
||||
);
|
||||
}
|
||||
|
||||
return genSqlSrchStr({ queryObj, field, join: genObject?.join });
|
||||
});
|
||||
|
||||
if (sqlSearhString?.[0] && sqlSearhString.find((str) => str)) {
|
||||
const stringOperator = genObject?.searchOperator || "AND";
|
||||
queryString += ` WHERE ${sqlSearhString.join(` ${stringOperator} `)}`;
|
||||
|
||||
@ -1012,9 +1012,24 @@ export type ServerQueryParam<
|
||||
};
|
||||
join?: ServerQueryParamsJoin<K>[];
|
||||
group?: (keyof T)[];
|
||||
countSubQueries?: ServerQueryParamsCount[];
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export type ServerQueryParamsCount = {
|
||||
table: string;
|
||||
srcTrgMap: {
|
||||
src: string;
|
||||
trg: string | ServerQueryParamsCountSrcTrgMap;
|
||||
}[];
|
||||
alias: string;
|
||||
};
|
||||
|
||||
export type ServerQueryParamsCountSrcTrgMap = {
|
||||
table: string;
|
||||
field: string;
|
||||
};
|
||||
|
||||
export type TableSelectFieldsObject<
|
||||
T extends { [k: string]: any } = { [k: string]: any }
|
||||
> = {
|
||||
@ -1858,7 +1873,11 @@ export const ImageMimeTypes: (keyof sharp.FormatEnum)[] = [
|
||||
"jpg",
|
||||
] as const;
|
||||
|
||||
export const VideoMimeTypes = ["mp4", "wav"] as const;
|
||||
|
||||
export const FileMimeTypes = [
|
||||
...ImageMimeTypes,
|
||||
...VideoMimeTypes,
|
||||
"pdf",
|
||||
"csv",
|
||||
"json",
|
||||
@ -1879,8 +1898,6 @@ export const FileMimeTypes = [
|
||||
"css",
|
||||
] as const;
|
||||
|
||||
export const VideoMimeTypes = ["mp4", "wav"] as const;
|
||||
|
||||
export const CurrentlyEditedFieldActions = [
|
||||
"edit-field",
|
||||
"edit-index",
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { format } from "sql-formatter";
|
||||
import sqlGenerator from "../../functions/dsql/sql/sql-generator";
|
||||
import { APIResponseObject, DsqlCrudParam } from "../../types";
|
||||
import connDbHandler, { ConnDBHandlerQueryObject } from "../db/conn-db-handler";
|
||||
@ -85,11 +86,11 @@ export default async function <
|
||||
: undefined,
|
||||
errors: res?.errors,
|
||||
queryObject: {
|
||||
sql: queryObject?.string,
|
||||
sql: format(queryObject?.string || "") || undefined,
|
||||
params: queryObject?.values,
|
||||
},
|
||||
countQueryObject: {
|
||||
sql: countQueryObject?.string,
|
||||
sql: format(countQueryObject?.string || "") || undefined,
|
||||
params: countQueryObject?.values,
|
||||
},
|
||||
count: isSuccess
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { format } from "sql-formatter";
|
||||
import sqlDeleteGenerator from "../../functions/dsql/sql/sql-delete-generator";
|
||||
import {
|
||||
APIResponseObject,
|
||||
@ -94,7 +95,7 @@ export default async function dsqlCrud<
|
||||
success: Boolean(res.affectedRows),
|
||||
payload: res,
|
||||
queryObject: {
|
||||
sql: deleteQuery?.query || "",
|
||||
sql: format(deleteQuery?.query || ""),
|
||||
params: deleteQuery?.values || [],
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "5.4.3",
|
||||
"version": "5.4.4",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
@ -46,6 +46,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"mariadb": "^3.4.4",
|
||||
"nodemailer": "^6.9.14",
|
||||
"sanitize-html": "^2.13.1"
|
||||
"sanitize-html": "^2.13.1",
|
||||
"sql-formatter": "^15.6.10"
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user