This commit is contained in:
Benjamin Toby 2024-12-27 09:56:11 +01:00
parent e4590e74d9
commit 0a77a869f7
4 changed files with 13 additions and 9 deletions

View File

@ -131,14 +131,16 @@ function sqlGenerator({ tableName, genObject }) {
if (joinObj.selectFields) {
return joinObj.selectFields
.map((slFld) => {
if (typeof slFld == "string") {
return `${joinTableName}.${slFld}`;
} else if (typeof slFld == "object") {
let aliasSlctFld = `${joinTableName}.${slFld.field}`;
if (slFld.alias)
aliasSlctFld += ` as ${slFld.alias}`;
return aliasSlctFld;
.map((selectField) => {
if (typeof selectField == "string") {
return `${joinTableName}.${selectField}`;
} else if (typeof selectField == "object") {
let aliasSelectField = selectField.count
? `COUNT(${joinTableName}.${selectField.field})`
: `${joinTableName}.${selectField.field}`;
if (selectField.alias)
aliasSelectField += ` AS ${selectField.alias}`;
return aliasSelectField;
}
})
.join(",");

View File

@ -955,6 +955,7 @@ export type ServerQueryParamsJoin<Table extends string = string, Field extends o
selectFields?: (keyof Field | {
field: keyof Field;
alias?: string;
count?: boolean;
})[];
};
export type ServerQueryParamsJoinMatchObject<Field extends object = {

View File

@ -1141,6 +1141,7 @@ export type ServerQueryParamsJoin<
| {
field: keyof Field;
alias?: string;
count?: boolean;
}
)[];
};

View File

@ -1,6 +1,6 @@
{
"name": "@moduletrace/datasquirel",
"version": "3.2.0",
"version": "3.2.1",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"bin": {