baja-lite 1.5.20 → 1.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +1 -0
  2. package/code.js +195 -121
  3. package/package.json +1 -1
  4. package/sql.js +6 -6
package/README.md CHANGED
@@ -1 +1,2 @@
1
1
 
2
+ [文档](https://deepwiki.com/void-soul/baja-lite)
package/code.js CHANGED
@@ -47,112 +47,190 @@ const lxMap = {
47
47
  multipolygon: "Object",
48
48
  geometrycollection: "Object"
49
49
  };
50
+ function info(i) {
51
+ console.log(info2(i));
52
+ }
53
+ function warn(i) {
54
+ console.log(warn2(i));
55
+ }
56
+ function success(i) {
57
+ console.log(success2(i));
58
+ }
59
+ function error(i) {
60
+ console.log(error2(i));
61
+ }
62
+ function log(i) {
63
+ console.log(log2(i));
64
+ }
65
+ function info2(i) {
66
+ return `\x1b[46m\x1b[30m${i}\x1b[0m`;
67
+ }
68
+ function warn2(i) {
69
+ return `\x1b[43m\x1b[30m${i}\x1b[0m`;
70
+ }
71
+ function success2(i) {
72
+ return `\x1b[42m\x1b[30m${i}\x1b[0m`;
73
+ }
74
+ function error2(i) {
75
+ return `\x1b[41m\x1b[30m${i}\x1b[0m`;
76
+ }
77
+ function log2(i) {
78
+ return `\x1b[47m\x1b[30m${i}\x1b[0m`;
79
+ }
80
+ let js = false;
81
+ function checkPath(p) {
82
+ let file = `${p}/baja.code.json`;
83
+ try {
84
+ info(`查找配置文件: ${file}`);
85
+ fs.statSync(file);
86
+ success(`发现配置文件: ${file}`);
87
+ return file;
88
+ }
89
+ catch (e1) {
90
+ try {
91
+ file = `${p}/baja.code.js`;
92
+ info(`查找配置文件: ${file}`);
93
+ fs.statSync(file);
94
+ success(`发现配置文件: ${file}`);
95
+ js = true;
96
+ return file;
97
+ }
98
+ catch (e2) {
99
+ }
100
+ }
101
+ return null;
102
+ }
50
103
  let force = false;
51
104
  let basepath = path.join(import.meta.dirname, '..', '..');
52
- try {
53
- fs.statSync(`${basepath}/baja.code.json`);
54
- }
55
- catch (error) {
105
+ let config = checkPath(basepath);
106
+ if (config === null) {
56
107
  basepath = path.join(import.meta.dirname, '..', '..', '..', '..', '..');
108
+ config = checkPath(basepath);
57
109
  }
58
- const config = path.join(basepath, 'baja.code.json');
59
- const templatePath = path.join(basepath, 'code-template');
60
- console.log(`
61
- **********************-----------
62
- 配置文件:
63
- 请在项目根目录添加文件:baja.code.json!配置示例:
64
- {
65
- "host": "",
66
- "port": "",
67
- "user": "",
68
- "password": "",
69
- "database": "",
110
+ function help1() {
111
+ console.log(`
112
+ **********************-----------
113
+ ${info2('配置文件:')}
114
+ 请在项目根目录添加文件:${warn2('baja.code.json')} 或者 ${warn2('baja.code.js(export defult {})')}
115
+ ${info2('配置示例:')}
116
+ {
70
117
 
71
- "command": {
72
- "entity": "src/{vueName}/{vueName}.entity.ts",
73
- "controller": "src/{vueName}/{vueName}.controller.ts",
74
- "service": "src/{vueName}/{vueName}.service.ts",
75
- "sql": "src/sql/{vueName}.mu",
76
- "module": "src/{vueName}/{vueName}.module.ts"
77
- },
78
- "commands": {
79
- "s": ["entity", "controller", "service", "sql", "module"]
80
- }
81
- "commands": {
82
- "s": ["entity", "controller", "service", "sql", "module"]
83
- },
84
- "output": "{ClassName}Module",
85
- "id"? : "uuidShort: true, notNull: true, uuid: true",
86
- "logicDeleteK"?: "逻辑删除字段名",
87
- "logicDeleteV"?: "逻辑删除值",如果是字符串需要这样 logicDeleteV: "'0'"
88
- "NotlogicDeleteV"?: "未逻辑删除值",如果是字符串需要这样 NotlogicDeleteV: "'0'",
89
- "skipColumns"?: ["跳过的列名1", "跳过的列名2"],
90
- "custom"?: (列名:string) => string; 该属性支持为每个数据库列自定义一个名称,例如 字段名为 ci_name 可通过custom改造为 Ci Name
118
+ "host": "",
119
+ "port": "",
120
+ "user": "",
121
+ "password": "",
122
+ "database": "",
123
+
124
+ "command": {
125
+ "entity": "src/{vueName}/{vueName}.entity.ts",
126
+ "controller": "src/{vueName}/{vueName}.controller.ts",
127
+ "service": "src/{vueName}/{vueName}.service.ts",
128
+ "sql": "src/sql/{vueName}.mu",
129
+ "module": "src/{vueName}/{vueName}.module.ts"
130
+ },
131
+ "commands": {
132
+ "s": ["entity", "controller", "service", "sql", "module"]
91
133
  }
92
- command是生成命令,这里声明命令同时定义文件生成路径:可用下面的变量替换.同时必须有同名模板.
93
- 路径是相对于项目根目录的
94
- commands是组合命令,上面表示输入s,同时生成:"entity", "controller", "service", "sql", "module"
95
- output 是生成后打印出的内容
96
- 模板转义:<%& 变量 %>
97
- **********************-----------
98
- **********************-----------
99
- **********************-----------
100
- 模板文件
101
- 请在项目根目录的code-template添加模板文件, 按照mustache(标签定义成了[ '<%', '%>' ])进行格式化,支持使用的变量:
102
- ************* 以下假设表名为event_main_info,列名为sku_id,sku_name
103
- title // 字符串,表的注释
104
-
105
- tableName // 字符串,event_main_info
106
- className // 字符串,eventMainInfo
107
- ClassName // 字符串,EventMainInfo
108
- vueName // 字符串,event-main-info
109
- splitVueName // 字符串,event/main-info
110
- splitName // 字符串,event/main/info
111
- SplitName // 字符串,event/mainInfo
112
-
113
- columns // 数组, 元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name、JSFieldName 分别表示JS的注解,Type:表示JS类型,custom:自定义列名}
114
- column_names // 数组, 元素是列名字符串,格式是 sku_id,sku_name
115
- ColumnNames // 数组, 元素是列名字符串,格式是 skuId,skuName
116
- column_names_join // 字符串,列名join的字符串,格式是 "sku_id,sku_name"
117
- ColumnNames_join // 字符串,列名join的字符串,格式是 "skuId,skuName"
118
-
119
- column_names_joinT // 字符串,列名join的字符串,格式是 "t.sku_id,t.sku_name"
120
- ColumnNames_joinT // 字符串,列名join的字符串,格式是 "t.skuId,t.skuName"
121
-
122
- columns_no_id // 数组, 不含主键, 元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name, JSFieldName 分别表示JS的注解,Type:表示JS类型}
123
- column_names_no_id // 数组, 不含主键, 元素是列名字符串,格式是 sku_id,sku_name
124
- ColumnNames_no_id // 数组, 不含主键, 元素是列名字符串,格式是 skuId,skuName
125
- column_names_no_id_join // 字符串, 不含主键, 列名join的字符串,格式是 "sku_id,sku_name"
126
- ColumnNames_no_id_join // 字符串, 不含主键, 列名join的字符串,格式是 "skuId,skuName"
134
+ "commands": {
135
+ "s": ["entity", "controller", "service", "sql", "module"]
136
+ },
137
+ "output": "{ClassName}Module",
138
+ "id"? : "uuidShort: true, notNull: true, uuid: true",
139
+ "logicDeleteK"?: "逻辑删除字段名",
140
+ "logicDeleteV"?: "逻辑删除值",如果是字符串需要这样 logicDeleteV: "'0'"
141
+ "NotlogicDeleteV"?: "未逻辑删除值",如果是字符串需要这样 NotlogicDeleteV: "'0'",
142
+ "skipColumns"?: ["跳过的列名1", "跳过的列名2"],
143
+ "custom"?: (列名:string) => string; 该属性支持为每个数据库列自定义一个名称,例如 字段名为 ci_name 可通过custom改造为 Ci Name
144
+ }
145
+ ${warn2(`command`)}是生成命令,这里声明命令同时定义文件生成路径, 同时要求在模板中必须有对应模板. ${info2('路径是相对于项目根目录的相对路径')}.
146
+ ${warn2('commands')}是组合命令,上面的配置表示输入${error2('s')}同时生成:${success2('"entity", "controller", "service", "sql", "module"这几个模块')}
147
+ ${warn2('output')} 是生成后打印出的内容
148
+ `);
149
+ }
150
+ function help2() {
151
+ console.log(`
152
+ ${error2('模板文件说明')}
153
+ 使用${error2('mustache')}
154
+ ${warn2('模板变量输出')}${info2('<% 变量 %>')}
155
+ ${warn2('模板转义')}${info2('<%& 变量 %>')}
156
+ ${warn2('模板循环')}${info2('<%# 变量 %> <%/变量%>')}
157
+ ${warn2('模板路径')} 项目根目录的${error2('code-template')}
158
+ ${warn2('模板使用')} 在配置文件中的command下定义命令,每个命令的key
159
+ ${error2('变量说明')}
160
+ ---------------------------------------------------------------------------------------------------------------
161
+ ************* 以下假设表名为${error2('event_main_info')},列名为${error2('sku_id,sku_name')}
162
+ title // 字符串,表的注释
163
+
164
+ tableName // 字符串,event_main_info
165
+ className // 字符串,eventMainInfo
166
+ ClassName // 字符串,EventMainInfo
167
+ vueName // 字符串,event-main-info
168
+ splitVueName // 字符串,event/main-info
169
+ splitName // 字符串,event/main/info
170
+ SplitName // 字符串,event/mainInfo
171
+
172
+ columns // 数组, 元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name、JSFieldName 分别表示JS的注解,Type:表示JS类
173
+ 型,custom:自定义列名}
174
+ column_names // 数组, 元素是列名字符串,格式是 sku_id,sku_name
175
+ ColumnNames // 数组, 元素是列名字符串,格式是 skuId,skuName
176
+ column_names_join // 字符串,列名join的字符串,格式是 "sku_id,sku_name"
177
+ ColumnNames_join // 字符串,列名join的字符串,格式是 "skuId,skuName"
178
+
179
+ column_names_joinT // 字符串,列名join的字符串,格式是 "t.sku_id,t.sku_name"
180
+ ColumnNames_joinT // 字符串,列名join的字符串,格式是 "t.skuId,t.skuName"
127
181
 
182
+ columns_no_id // 数组, 不含主键, 元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name, JSFieldName 分别表示JS的注解,Type:表示JS类型
183
+ }
184
+ column_names_no_id // 数组, 不含主键, 元素是列名字符串,格式是 sku_id,sku_name
185
+ ColumnNames_no_id // 数组, 不含主键, 元素是列名字符串,格式是 skuId,skuName
186
+ column_names_no_id_join // 字符串, 不含主键, 列名join的字符串,格式是 "sku_id,sku_name"
187
+ ColumnNames_no_id_join // 字符串, 不含主键, 列名join的字符串,格式是 "skuId,skuName"
188
+
189
+
190
+ columns_no_skip // 数组, 不含跳过的列,元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name, JSFieldName 分别表示JS的注解,Type:表示JS类型}
191
+ column_names_no_skip // 数组, 不含跳过的列, 元素是列名字符串,格式是 sku_id,sku_name
192
+ ColumnNames_no_skip // 数组, 不含跳过的列, 元素是列名字符串,格式是 skuId,skuName
193
+ column_names_no_skip_join // 数组, 不含跳过的列, 元素是列名字符串,格式是 "sku_id,sku_name"
194
+ ColumnNames_no_skip_join // 数组, 不含跳过的列, 元素是列名字符串,格式是 "skuId,skuName"
128
195
 
129
- columns_no_skip // 数组, 不含跳过的列,元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name, JSFieldName 分别表示JS的注解,Type:表示JS类型}
130
- column_names_no_skip // 数组, 不含跳过的列, 元素是列名字符串,格式是 sku_id,sku_name
131
- ColumnNames_no_skip // 数组, 不含跳过的列, 元素是列名字符串,格式是 skuId,skuName
132
- column_names_no_skip_join // 数组, 不含跳过的列, 元素是列名字符串,格式是 "sku_id,sku_name"
133
- ColumnNames_no_skip_join // 数组, 不含跳过的列, 元素是列名字符串,格式是 "skuId,skuName"
196
+ ids // 数组, 只有主键, 元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name, JSFieldName 分别表示JS的注解,Type:表示JS类型}
197
+ id_names // 数组, 只有主键, 元素是列名字符串,格式是 sku_id,sku_name
198
+ IdNames // 数组, 只有主键, 元素是列名字符串,格式是 skuId,skuName
199
+ id_names_join // 字符串,列名join的字符串,格式是 "sku_id,sku_name"
200
+ IdNames_join // 字符串,列名join的字符串,格式是 "skuId,skuName"
134
201
 
135
- ids // 数组, 只有主键, 元素格式为{comment:注释,name: sku_id,Name: skuId,NAME: SkuId,Field:表示字段的注解,JSField_name, JSFieldName 分别表示JS的注解,Type:表示JS类型}
136
- id_names // 数组, 只有主键, 元素是列名字符串,格式是 sku_id,sku_name
137
- IdNames // 数组, 只有主键, 元素是列名字符串,格式是 skuId,skuName
138
- id_names_join // 字符串,列名join的字符串,格式是 "sku_id,sku_name"
139
- IdNames_join // 字符串,列名join的字符串,格式是 "skuId,skuName"
140
-
141
- modelName // 推断出的模块名称,可能为空字符串, 如果表名为event_main_info, 则模块为 event
142
- modelPath // 模块名称实际就影响访问路径,所以这里会直接拼好controller的模块访问路径,如果模块为空,则该属性就是空字符串,否则是 /模块名称/
143
-
144
- logicDelete // 逻辑删除的查询条件,可以附加在sql条件的末尾,可能是空的
145
- ---------------------------------------------------------------------------------------------------------------
146
- .命令 table1,table2,table3:模块名称
147
- table=. 表示扫描全库表
148
- :模块名称 可以省略
149
- -----
150
- .force: 切换是否覆盖
202
+ modelName // 推断出的模块名称,可能为空字符串, 如果表名为event_main_info, 则模块为 event
203
+ modelPath // 模块名称实际就影响访问路径,所以这里会直接拼好controller的模块访问路径,如果模块为空,则该属性就是空字符串,否则是 /模块名称/
204
+
205
+ logicDelete // 逻辑删除的查询条件,可以附加在sql条件的末尾,可能是空的
206
+ ---------------------------------------------------------------------------------------------------------------
207
+ ${warn2('特殊命令')}
208
+ ${warn2('多表操作')} .命令 table1,table2,table3:模块名称 ${info2(':模块名称 可以省略')}
209
+ ${warn2('全库操作')} .命令 . ${info2('注意:.表示全表')}
210
+ ${warn2('覆盖生成')} .force
211
+ ${warn2('配置说明')} .help1
212
+ ${warn2('模板说明')} .help2
213
+ -----
151
214
  `);
215
+ }
216
+ if (config === null) {
217
+ error('NOT FOUND Config File!!');
218
+ help1();
219
+ throw new Error('NOT FOUND Config File');
220
+ }
221
+ const templatePath = path.join(basepath, 'code-template');
222
+ help2();
152
223
  try {
153
224
  const outputs = new Set();
154
- const _configData = fs.readFileSync(config, { encoding: 'utf-8' }).toString();
155
- const configData = JSON.parse(_configData);
225
+ let configData;
226
+ if (js === false) {
227
+ const _configData = fs.readFileSync(config, { encoding: 'utf-8' }).toString();
228
+ configData = JSON.parse(_configData);
229
+ }
230
+ else {
231
+ const _configData = fs.readFileSync(config, { encoding: 'utf-8' }).toString();
232
+ configData = new Function(_configData.replace('export default', 'return'))();
233
+ }
156
234
  configData.skipColumns ?? (configData.skipColumns = []);
157
235
  configData.command ?? (configData.command = {});
158
236
  configData.commands ?? (configData.commands = {});
@@ -162,10 +240,10 @@ try {
162
240
  configData.logicDeleteV ?? (configData.logicDeleteV = 0);
163
241
  configData.NotlogicDeleteV ?? (configData.NotlogicDeleteV = 0);
164
242
  if (!configData.host || !configData.port || !configData.user || !configData.password || !configData.database) {
165
- console.error(`[错误]配置文件缺少必要的参数: host, port, user, password, database`);
243
+ error(`[错误]配置文件缺少必要的参数: host, port, user, password, database`);
166
244
  }
167
245
  if (!fs.existsSync(templatePath)) {
168
- console.error(`[错误]模板文件夹不存在,请在项目根目录创建code-template文件夹`);
246
+ error(`[错误]模板文件夹不存在,请在项目根目录创建code-template文件夹`);
169
247
  }
170
248
  const templates = Object.fromEntries(fs.readdirSync(templatePath).map(r => [path.basename(r, '.mu'), fs.readFileSync(path.join(templatePath, r), { encoding: 'utf-8' }).toString()]));
171
249
  const pool = createPool({
@@ -286,7 +364,7 @@ try {
286
364
  if (input !== '.') {
287
365
  const checkTable = input.split(/,|\s/).map(r => r.trim());
288
366
  if (checkTable.length !== tables.length) {
289
- console.error(`[错误] 输入的表与数据库查询返回表不符,数据库返回${tables.length}个:${tables.map(i => i.tableName).join(',')}`);
367
+ error(`[错误] 输入的表与数据库查询返回表不符,数据库返回${tables.length}个:${tables.map(i => i.tableName).join(',')}`);
290
368
  return;
291
369
  }
292
370
  }
@@ -338,7 +416,7 @@ try {
338
416
  };
339
417
  const template = templates[command];
340
418
  if (!template) {
341
- console.error(`[错误] ${command} 未定义模板!`);
419
+ error(`[错误] ${command} 未定义模板!`);
342
420
  return;
343
421
  }
344
422
  const txt = mustache.render(template, data, {}, ['<%', '%>']);
@@ -348,24 +426,18 @@ try {
348
426
  const filePath = path.join(basepath, fileName);
349
427
  const dirname = path.dirname(filePath);
350
428
  mkdir('-p', dirname);
351
- // try {
352
- // fs.statSync(dirname);
353
- // } catch (error) {
354
- // fs.mkdirSync(dirname);
355
- // console.info(`[生成] ${dirname}`);
356
- // }
357
429
  try {
358
430
  fs.statSync(filePath);
359
431
  if (force === false) {
360
- console.warn(`[跳过] ${filePath}`);
432
+ warn(`[跳过] ${filePath}`);
361
433
  return;
362
434
  }
363
435
  else {
364
- console.warn(`[覆盖] ${filePath}`);
436
+ warn(`[覆盖] ${filePath}`);
365
437
  }
366
438
  }
367
439
  catch (error) {
368
- console.info(`[生成] ${filePath}`);
440
+ info(`[生成] ${filePath}`);
369
441
  }
370
442
  if (configData.output) {
371
443
  outputs.add(configData.output.replace(/{([a-zA-Z]+)}/g, (a, b) => data[b]));
@@ -377,24 +449,24 @@ try {
377
449
  const replServer = start();
378
450
  function defineCommand(command, comands) {
379
451
  if (comands) {
380
- console.log(`[组合]${command}>${comands.join(',')}注册成功`);
452
+ log(`\x1b[42m\x1b[30m[组合]${command}>${comands.join(',')}注册成功\x1b[0m`);
381
453
  }
382
454
  else {
383
- console.log(`[命令]${command}注册成功`);
455
+ log(`\x1b[42m\x1b[30m[命令]${command}注册成功\x1b[0m`);
384
456
  }
385
457
  if (comands) {
386
458
  replServer.defineCommand(command, async (input) => {
387
459
  outputs.clear();
388
460
  const inputs = input.match(/([^:]+):{0,1}([a-zA-Z0-9]*)/);
389
461
  if (inputs?.length !== 3) {
390
- return console.error(`[错误]命令格式应为: table1,table2[:模块名]`);
462
+ return error(`[错误]命令格式应为: table1,table2[:模块名]`);
391
463
  }
392
464
  const [_, tables, modelName] = inputs;
393
465
  for (const c of comands) {
394
466
  await excute(c, tables, modelName ?? '');
395
467
  }
396
- console.info('执行完毕!下面打印生成的输出');
397
- console.info(Array.from(outputs).join(','));
468
+ info('执行完毕!下面打印生成的输出');
469
+ info(Array.from(outputs).join(','));
398
470
  });
399
471
  }
400
472
  else {
@@ -402,23 +474,25 @@ try {
402
474
  outputs.clear();
403
475
  const inputs = input.match(/([^:]+):{0,1}([a-zA-Z0-9]*)/);
404
476
  if (inputs?.length !== 3) {
405
- return console.error(`[错误]命令格式应为: table1,table2[:模块名]`);
477
+ return error(`[错误]命令格式应为: table1,table2[:模块名]`);
406
478
  }
407
479
  const [_, tables, modelName] = inputs;
408
480
  await excute(command, tables, modelName ?? '');
409
- console.info('执行完毕!下面打印生成的输出');
410
- console.info(Array.from(outputs).join(','));
481
+ info('执行完毕!下面打印生成的输出');
482
+ info(Array.from(outputs).join(','));
411
483
  });
412
484
  }
413
485
  }
414
486
  replServer.defineCommand('force', () => {
415
487
  force = !force;
416
- console.log(force ? '覆盖生成' : '不覆盖生成!');
488
+ log(force ? '覆盖生成' : '不覆盖生成!');
417
489
  });
490
+ replServer.defineCommand('help1', help1);
491
+ replServer.defineCommand('help2', help2);
418
492
  if (configData.command) {
419
493
  for (const command of Object.keys(configData.command)) {
420
494
  if (!templates[command]) {
421
- console.error(`命令:${command}没有定义模板,该命令不会生效`);
495
+ error(`命令:${command}没有定义模板,该命令不会生效`);
422
496
  }
423
497
  else {
424
498
  defineCommand(command);
@@ -428,9 +502,9 @@ try {
428
502
  if (configData.commands) {
429
503
  for (const [command, commands] of Object.entries(configData.commands)) {
430
504
  const keys = commands;
431
- const error = keys.filter(k => !templates[k]).join(',');
432
- if (error) {
433
- console.error(`组合命令:${command}定义了${commands},但是${error}没有定义模板,该命令不会生效`);
505
+ const e = keys.filter(k => !templates[k]).join(',');
506
+ if (e) {
507
+ error(`组合命令:${command}定义了${commands},但是${e}没有定义模板,该命令不会生效`);
434
508
  }
435
509
  else {
436
510
  defineCommand(command, keys);
@@ -439,5 +513,5 @@ try {
439
513
  }
440
514
  }
441
515
  catch (error) {
442
- console.error(error);
516
+ error(error);
443
517
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baja-lite",
3
- "version": "1.5.20",
3
+ "version": "1.5.22",
4
4
  "description": "some util for self",
5
5
  "homepage": "https://github.com/void-soul/baja-lite",
6
6
  "repository": {
package/sql.js CHANGED
@@ -3783,12 +3783,12 @@ class StreamQuery {
3783
3783
  page(pageNumber, pageSize) { this._startRow = ((pageNumber || 1) - 1) * pageSize; this._pageSize = pageSize; return this; }
3784
3784
  distinct(on = true) { this._distinct = on; return this; }
3785
3785
  /** COUNT(DISTINCT key) */
3786
- countDistinct(key, countName) { this._columns.push(`COUNT(DISTINCT t.${this[_fields][String(key)]?.C2()}) ${countName || `t.${this[_fields][String(key)]?.C2()}`}`); return this; }
3786
+ countDistinct(key, countName) { this._columns.push(`COUNT(DISTINCT t.${this[_fields][String(key)]?.C2()}) ${countName || this[_fields][String(key)]?.C2()}`); return this; }
3787
3787
  count(countName) { this._columns.push(`COUNT(1) ${countName ?? 'ct'}`); return this; }
3788
- sum(key, legName, distinct) { this._columns.push(`SUM(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || `t.${this[_fields][String(key)]?.C2()}`}`); return this; }
3789
- avg(key, legName, distinct) { this._columns.push(`AVG(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || `t.${this[_fields][String(key)]?.C2()}`}`); return this; }
3790
- max(key, legName, distinct) { this._columns.push(`MAX(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || `t.${this[_fields][String(key)]?.C2()}`}`); return this; }
3791
- min(key, legName, distinct) { this._columns.push(`MIN(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || `t.${this[_fields][String(key)]?.C2()}`}`); return this; }
3788
+ sum(key, legName, distinct) { this._columns.push(`SUM(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || this[_fields][String(key)]?.C2()}`); return this; }
3789
+ avg(key, legName, distinct) { this._columns.push(`AVG(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || this[_fields][String(key)]?.C2()}`); return this; }
3790
+ max(key, legName, distinct) { this._columns.push(`MAX(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || this[_fields][String(key)]?.C2()}`); return this; }
3791
+ min(key, legName, distinct) { this._columns.push(`MIN(${distinct ? 'DISTINCT' : ''} t.${this[_fields][String(key)]?.C2()}) ${legName || this[_fields][String(key)]?.C2()}`); return this; }
3792
3792
  /** GROUP_CONCAT([DISTINCT] key [ORDER BY :asc ASC] [ORDER BY :asc DESC] [SEPARATOR :separator]) */
3793
3793
  groupConcat(key, param) {
3794
3794
  this._columns.push(`GROUP_CONCAT(
@@ -3796,7 +3796,7 @@ class StreamQuery {
3796
3796
  ${param && param.asc && param.asc.length > 0 ? `ORDER BY ${param.asc.map(i => `t.${this[_fields][String(i)]?.C2()} ASC`)} ` : ''}
3797
3797
  ${param && param.desc && param.desc.length > 0 ? `${param && param.asc && param.asc.length > 0 ? '' : 'ORDER BY'} ${param.desc.map(i => `t.${this[_fields][String(i)]?.C2()} DESC`)} ` : ''}
3798
3798
  SEPARATOR '${param && param.separator || ','}'
3799
- ) ${param && param.groupName || `t.${this[_fields][String(key)]?.C2()}`}`);
3799
+ ) ${param && param.groupName || this[_fields][String(key)]?.C2()}`);
3800
3800
  return this;
3801
3801
  }
3802
3802
  select(...key) { this._columns.push(...(key.map(k => `t.${this[_fields][String(k)].C3()}`))); return this; }