Updates
This commit is contained in:
parent
e4590e74d9
commit
0a77a869f7
@ -131,14 +131,16 @@ function sqlGenerator({ tableName, genObject }) {
|
|||||||
|
|
||||||
if (joinObj.selectFields) {
|
if (joinObj.selectFields) {
|
||||||
return joinObj.selectFields
|
return joinObj.selectFields
|
||||||
.map((slFld) => {
|
.map((selectField) => {
|
||||||
if (typeof slFld == "string") {
|
if (typeof selectField == "string") {
|
||||||
return `${joinTableName}.${slFld}`;
|
return `${joinTableName}.${selectField}`;
|
||||||
} else if (typeof slFld == "object") {
|
} else if (typeof selectField == "object") {
|
||||||
let aliasSlctFld = `${joinTableName}.${slFld.field}`;
|
let aliasSelectField = selectField.count
|
||||||
if (slFld.alias)
|
? `COUNT(${joinTableName}.${selectField.field})`
|
||||||
aliasSlctFld += ` as ${slFld.alias}`;
|
: `${joinTableName}.${selectField.field}`;
|
||||||
return aliasSlctFld;
|
if (selectField.alias)
|
||||||
|
aliasSelectField += ` AS ${selectField.alias}`;
|
||||||
|
return aliasSelectField;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.join(",");
|
.join(",");
|
||||||
|
1
package-shared/types/index.d.ts
vendored
1
package-shared/types/index.d.ts
vendored
@ -955,6 +955,7 @@ export type ServerQueryParamsJoin<Table extends string = string, Field extends o
|
|||||||
selectFields?: (keyof Field | {
|
selectFields?: (keyof Field | {
|
||||||
field: keyof Field;
|
field: keyof Field;
|
||||||
alias?: string;
|
alias?: string;
|
||||||
|
count?: boolean;
|
||||||
})[];
|
})[];
|
||||||
};
|
};
|
||||||
export type ServerQueryParamsJoinMatchObject<Field extends object = {
|
export type ServerQueryParamsJoinMatchObject<Field extends object = {
|
||||||
|
@ -1141,6 +1141,7 @@ export type ServerQueryParamsJoin<
|
|||||||
| {
|
| {
|
||||||
field: keyof Field;
|
field: keyof Field;
|
||||||
alias?: string;
|
alias?: string;
|
||||||
|
count?: boolean;
|
||||||
}
|
}
|
||||||
)[];
|
)[];
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "3.2.0",
|
"version": "3.2.1",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
Loading…
Reference in New Issue
Block a user