Updates
This commit is contained in:
parent
8bcb35a8f0
commit
58984214fc
@ -16,7 +16,7 @@ exports.default = checks;
|
||||
const lodash_1 = __importDefault(require("lodash"));
|
||||
function checks(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ table, allowedTables, query, body, method, getMiddleware, postMiddleware, putMiddleware, deleteMiddleware, crudMiddleware, targetId, }) {
|
||||
var _b, _c, _d, _e;
|
||||
var _b, _c, _d, _e, _f;
|
||||
const allowedTable = allowedTables.find((tbl) => tbl.table == table);
|
||||
if (!allowedTable) {
|
||||
throw new Error(`Can't Access this table: \`${table}\``);
|
||||
@ -51,8 +51,9 @@ function checks(_a) {
|
||||
}
|
||||
}
|
||||
if ((_e = newQuery === null || newQuery === void 0 ? void 0 : newQuery.searchQuery) === null || _e === void 0 ? void 0 : _e.join) {
|
||||
for (let i = 0; i < newQuery.searchQuery.join.length; i++) {
|
||||
const join = newQuery.searchQuery.join[i];
|
||||
const alljoins = (_f = newQuery === null || newQuery === void 0 ? void 0 : newQuery.searchQuery) === null || _f === void 0 ? void 0 : _f.join.flat();
|
||||
for (let i = 0; i < alljoins.length; i++) {
|
||||
const join = alljoins[i];
|
||||
if (!join)
|
||||
continue;
|
||||
const joinTableName = join.tableName;
|
||||
|
||||
@ -171,6 +171,7 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
str +=
|
||||
"," +
|
||||
genObject.join
|
||||
.flat()
|
||||
.filter((j) => !(0, lodash_1.isUndefined)(j))
|
||||
.map((joinObj) => {
|
||||
const joinTableName = joinObj.alias
|
||||
@ -214,6 +215,7 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
||||
str +=
|
||||
" " +
|
||||
genObject.join
|
||||
.flat()
|
||||
.filter((j) => !(0, lodash_1.isUndefined)(j))
|
||||
.map((join) => {
|
||||
return (join.joinType +
|
||||
|
||||
2
dist/package-shared/types/index.d.ts
vendored
2
dist/package-shared/types/index.d.ts
vendored
@ -851,7 +851,7 @@ export type ServerQueryParam<T extends {
|
||||
addUserId?: {
|
||||
fieldName: keyof T;
|
||||
};
|
||||
join?: (ServerQueryParamsJoin<K> | undefined)[];
|
||||
join?: (ServerQueryParamsJoin<K> | ServerQueryParamsJoin<K>[] | undefined)[];
|
||||
group?: (keyof T)[];
|
||||
countSubQueries?: ServerQueryParamsCount[];
|
||||
fullTextSearch?: ServerQueryParamFullTextSearch<T>;
|
||||
|
||||
@ -75,8 +75,10 @@ export default async function checks<
|
||||
}
|
||||
|
||||
if (newQuery?.searchQuery?.join) {
|
||||
for (let i = 0; i < newQuery.searchQuery.join.length; i++) {
|
||||
const join = newQuery.searchQuery.join[i];
|
||||
const alljoins = newQuery?.searchQuery?.join.flat();
|
||||
|
||||
for (let i = 0; i < alljoins.length; i++) {
|
||||
const join = alljoins[i];
|
||||
|
||||
if (!join) continue;
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ export default function sqlGenerator<
|
||||
field,
|
||||
}: {
|
||||
queryObj: ServerQueryQueryObject[string];
|
||||
join?: (ServerQueryParamsJoin | undefined)[];
|
||||
join?: (ServerQueryParamsJoin | ServerQueryParamsJoin[] | undefined)[];
|
||||
field?: string;
|
||||
}) {
|
||||
const finalFieldName = (() => {
|
||||
@ -248,6 +248,7 @@ export default function sqlGenerator<
|
||||
str +=
|
||||
"," +
|
||||
genObject.join
|
||||
.flat()
|
||||
.filter((j) => !isUndefined(j))
|
||||
.map((joinObj) => {
|
||||
const joinTableName = joinObj.alias
|
||||
@ -296,6 +297,7 @@ export default function sqlGenerator<
|
||||
str +=
|
||||
" " +
|
||||
genObject.join
|
||||
.flat()
|
||||
.filter((j) => !isUndefined(j))
|
||||
.map((join) => {
|
||||
return (
|
||||
|
||||
@ -1043,7 +1043,11 @@ export type ServerQueryParam<
|
||||
addUserId?: {
|
||||
fieldName: keyof T;
|
||||
};
|
||||
join?: (ServerQueryParamsJoin<K> | undefined)[];
|
||||
join?: (
|
||||
| ServerQueryParamsJoin<K>
|
||||
| ServerQueryParamsJoin<K>[]
|
||||
| undefined
|
||||
)[];
|
||||
group?: (keyof T)[];
|
||||
countSubQueries?: ServerQueryParamsCount[];
|
||||
fullTextSearch?: ServerQueryParamFullTextSearch<T>;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/datasquirel",
|
||||
"version": "5.7.19",
|
||||
"version": "5.7.20",
|
||||
"description": "Cloud-based SQL data management tool",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user