baja-lite 1.2.1 → 1.3.1
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.
- package/boot-remote.js +2 -1
- package/boot.js +2 -1
- package/code.js +3 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +16 -15
- package/sql.d.ts +9 -84
- package/sql.js +83 -338
- package/test-mysql.js +72 -98
- package/test-postgresql.js +2 -1
- package/test-sqlite.js +2 -1
- package/validate.d.ts +170 -0
- package/validate.js +378 -0
- package/wx/mini.d.ts +2 -2
- package/wx/mini.js +1 -1
- package/wx/organ.d.ts +2 -2
- package/wx/organ.js +1 -1
package/sql.js
CHANGED
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var _b, _c, _d, _e;
|
|
11
11
|
var _f, _g, _h, _j;
|
|
12
12
|
import { decode, DecodeError, encode, ExtensionCodec } from "@msgpack/msgpack";
|
|
13
|
+
import { _columns, _columnsNoId, _def, _deleteState, _fields, _Hump, _ids, _index, _logicIds, _stateFileName, DBType, Field } from 'baja-lite-field';
|
|
13
14
|
import HTML from 'html-parse-stringify';
|
|
14
15
|
import * as ite from 'iterare';
|
|
15
16
|
import LGet from 'lodash.get';
|
|
@@ -57,16 +58,7 @@ const _tableName = Symbol('tableName');
|
|
|
57
58
|
const _className = Symbol('className');
|
|
58
59
|
const _ClassName = Symbol('ClassName');
|
|
59
60
|
const _vueName = Symbol('vueName');
|
|
60
|
-
const _ids = Symbol('ids');
|
|
61
|
-
const _logicIds = Symbol('logicIds');
|
|
62
|
-
const _columns = Symbol('columns');
|
|
63
|
-
const _columnsNoId = Symbol('columnsNoId');
|
|
64
|
-
const _fields = Symbol('fields');
|
|
65
|
-
const _stateFileName = Symbol('stateFileName');
|
|
66
|
-
const _deleteState = Symbol('deleteState');
|
|
67
61
|
const _transformer = Symbol('transformer');
|
|
68
|
-
const _index = Symbol('index');
|
|
69
|
-
const _def = Symbol('def');
|
|
70
62
|
const _comment = Symbol('comment');
|
|
71
63
|
export const _sqlCache = Symbol('sqlMap');
|
|
72
64
|
export const _dao = Symbol('dao');
|
|
@@ -81,7 +73,6 @@ const _SqlOption = Symbol('SqlOption');
|
|
|
81
73
|
const _resultMap = Symbol('resultMap');
|
|
82
74
|
const _resultMap_SQLID = Symbol('resultMap_SQLID');
|
|
83
75
|
export const _enums = Symbol('_enums');
|
|
84
|
-
export const _Hump = Symbol('Hump');
|
|
85
76
|
export const _GlobalSqlOption = Symbol('GlobalSqlOption');
|
|
86
77
|
export const _EventBus = Symbol('EventBus');
|
|
87
78
|
export const _path = Symbol('path');
|
|
@@ -95,17 +86,6 @@ export const logger = process.env['NODE_ENV'] !== 'production' ? pino({
|
|
|
95
86
|
globalThis[_resultMap_SQLID] = {};
|
|
96
87
|
// #endregion
|
|
97
88
|
// #region 可选配置
|
|
98
|
-
export var DBType;
|
|
99
|
-
(function (DBType) {
|
|
100
|
-
DBType[DBType["Mysql"] = 0] = "Mysql";
|
|
101
|
-
DBType[DBType["Postgresql"] = 1] = "Postgresql";
|
|
102
|
-
DBType[DBType["Sqlite"] = 2] = "Sqlite";
|
|
103
|
-
DBType[DBType["Mongo"] = 3] = "Mongo";
|
|
104
|
-
DBType[DBType["SqliteRemote"] = 4] = "SqliteRemote";
|
|
105
|
-
DBType[DBType["Redis"] = 5] = "Redis";
|
|
106
|
-
DBType[DBType["RedisLock"] = 6] = "RedisLock";
|
|
107
|
-
})(DBType || (DBType = {}));
|
|
108
|
-
;
|
|
109
89
|
export var MapperIfUndefined;
|
|
110
90
|
(function (MapperIfUndefined) {
|
|
111
91
|
MapperIfUndefined[MapperIfUndefined["Null"] = 0] = "Null";
|
|
@@ -214,33 +194,6 @@ export var SelectResult;
|
|
|
214
194
|
/** 多行多列并封装ArrayList */
|
|
215
195
|
SelectResult[SelectResult["RS_CS_List"] = 7] = "RS_CS_List";
|
|
216
196
|
})(SelectResult || (SelectResult = {}));
|
|
217
|
-
export var SqlType;
|
|
218
|
-
(function (SqlType) {
|
|
219
|
-
SqlType[SqlType["tinyint"] = 0] = "tinyint";
|
|
220
|
-
SqlType[SqlType["smallint"] = 1] = "smallint";
|
|
221
|
-
SqlType[SqlType["mediumint"] = 2] = "mediumint";
|
|
222
|
-
SqlType[SqlType["int"] = 3] = "int";
|
|
223
|
-
SqlType[SqlType["bigint"] = 4] = "bigint";
|
|
224
|
-
SqlType[SqlType["float"] = 5] = "float";
|
|
225
|
-
SqlType[SqlType["double"] = 6] = "double";
|
|
226
|
-
SqlType[SqlType["decimal"] = 7] = "decimal";
|
|
227
|
-
SqlType[SqlType["date"] = 8] = "date";
|
|
228
|
-
SqlType[SqlType["time"] = 9] = "time";
|
|
229
|
-
SqlType[SqlType["year"] = 10] = "year";
|
|
230
|
-
SqlType[SqlType["datetime"] = 11] = "datetime";
|
|
231
|
-
SqlType[SqlType["timestamp"] = 12] = "timestamp";
|
|
232
|
-
SqlType[SqlType["char"] = 13] = "char";
|
|
233
|
-
SqlType[SqlType["varchar"] = 14] = "varchar";
|
|
234
|
-
SqlType[SqlType["tinyblob"] = 15] = "tinyblob";
|
|
235
|
-
SqlType[SqlType["tinytext"] = 16] = "tinytext";
|
|
236
|
-
SqlType[SqlType["blob"] = 17] = "blob";
|
|
237
|
-
SqlType[SqlType["text"] = 18] = "text";
|
|
238
|
-
SqlType[SqlType["mediumblob"] = 19] = "mediumblob";
|
|
239
|
-
SqlType[SqlType["mediumtext"] = 20] = "mediumtext";
|
|
240
|
-
SqlType[SqlType["longblob"] = 21] = "longblob";
|
|
241
|
-
SqlType[SqlType["longtext"] = 22] = "longtext";
|
|
242
|
-
SqlType[SqlType["json"] = 23] = "json";
|
|
243
|
-
})(SqlType || (SqlType = {}));
|
|
244
197
|
export var ColumnMode;
|
|
245
198
|
(function (ColumnMode) {
|
|
246
199
|
ColumnMode[ColumnMode["NONE"] = 0] = "NONE";
|
|
@@ -271,7 +224,7 @@ class MysqlConnection {
|
|
|
271
224
|
}
|
|
272
225
|
;
|
|
273
226
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
274
|
-
logger.trace(sql
|
|
227
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
275
228
|
}
|
|
276
229
|
return new Promise(async (resolve, reject) => {
|
|
277
230
|
try {
|
|
@@ -304,7 +257,7 @@ class MysqlConnection {
|
|
|
304
257
|
}
|
|
305
258
|
;
|
|
306
259
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
307
|
-
logger.trace(sql
|
|
260
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
308
261
|
}
|
|
309
262
|
return new Promise(async (resolve, reject) => {
|
|
310
263
|
try {
|
|
@@ -340,7 +293,7 @@ class MysqlConnection {
|
|
|
340
293
|
}
|
|
341
294
|
;
|
|
342
295
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
343
|
-
logger.trace(sql
|
|
296
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
344
297
|
}
|
|
345
298
|
return new Promise(async (resolve, reject) => {
|
|
346
299
|
try {
|
|
@@ -374,7 +327,7 @@ class MysqlConnection {
|
|
|
374
327
|
}
|
|
375
328
|
;
|
|
376
329
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
377
|
-
logger.trace(sql
|
|
330
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
378
331
|
}
|
|
379
332
|
return new Promise(async (resolve, reject) => {
|
|
380
333
|
try {
|
|
@@ -408,7 +361,7 @@ class MysqlConnection {
|
|
|
408
361
|
}
|
|
409
362
|
;
|
|
410
363
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
411
|
-
logger.trace(sql
|
|
364
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
412
365
|
}
|
|
413
366
|
return new Promise(async (resolve, reject) => {
|
|
414
367
|
try {
|
|
@@ -550,7 +503,7 @@ class PostgresqlConnection {
|
|
|
550
503
|
}
|
|
551
504
|
;
|
|
552
505
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
553
|
-
logger.trace(sql
|
|
506
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
554
507
|
}
|
|
555
508
|
return new Promise(async (resolve, reject) => {
|
|
556
509
|
try {
|
|
@@ -587,7 +540,7 @@ class PostgresqlConnection {
|
|
|
587
540
|
}
|
|
588
541
|
;
|
|
589
542
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
590
|
-
logger.trace(sql
|
|
543
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
591
544
|
}
|
|
592
545
|
return new Promise(async (resolve, reject) => {
|
|
593
546
|
try {
|
|
@@ -627,7 +580,7 @@ class PostgresqlConnection {
|
|
|
627
580
|
}
|
|
628
581
|
;
|
|
629
582
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
630
|
-
logger.trace(sql
|
|
583
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
631
584
|
}
|
|
632
585
|
return new Promise(async (resolve, reject) => {
|
|
633
586
|
try {
|
|
@@ -665,7 +618,7 @@ class PostgresqlConnection {
|
|
|
665
618
|
}
|
|
666
619
|
;
|
|
667
620
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
668
|
-
logger.trace(sql
|
|
621
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
669
622
|
}
|
|
670
623
|
return new Promise(async (resolve, reject) => {
|
|
671
624
|
try {
|
|
@@ -703,7 +656,7 @@ class PostgresqlConnection {
|
|
|
703
656
|
}
|
|
704
657
|
;
|
|
705
658
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
706
|
-
logger.trace(sql
|
|
659
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
707
660
|
}
|
|
708
661
|
return new Promise(async (resolve, reject) => {
|
|
709
662
|
try {
|
|
@@ -850,7 +803,7 @@ class SqliteConnection {
|
|
|
850
803
|
}
|
|
851
804
|
;
|
|
852
805
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
853
|
-
logger.trace(sql
|
|
806
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
854
807
|
}
|
|
855
808
|
const result = this[_daoConnection].prepare(sql).run(params ?? {});
|
|
856
809
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
@@ -881,7 +834,7 @@ class SqliteConnection {
|
|
|
881
834
|
}
|
|
882
835
|
;
|
|
883
836
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
884
|
-
logger.trace(sql
|
|
837
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
885
838
|
}
|
|
886
839
|
return this[_daoConnection].prepare(sql).pluck().get(params ?? {});
|
|
887
840
|
}
|
|
@@ -906,7 +859,7 @@ class SqliteConnection {
|
|
|
906
859
|
}
|
|
907
860
|
;
|
|
908
861
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
909
|
-
logger.trace(sql
|
|
862
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
910
863
|
}
|
|
911
864
|
return this[_daoConnection].prepare(sql).get(params ?? {});
|
|
912
865
|
}
|
|
@@ -932,7 +885,7 @@ class SqliteConnection {
|
|
|
932
885
|
}
|
|
933
886
|
;
|
|
934
887
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
935
|
-
logger.trace(sql
|
|
888
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
936
889
|
}
|
|
937
890
|
return this[_daoConnection].prepare(sql).raw().all(params ?? {});
|
|
938
891
|
}
|
|
@@ -958,7 +911,7 @@ class SqliteConnection {
|
|
|
958
911
|
}
|
|
959
912
|
;
|
|
960
913
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
961
|
-
logger.trace(sql
|
|
914
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
962
915
|
}
|
|
963
916
|
return this[_daoConnection].prepare(sql).all(params ?? {});
|
|
964
917
|
}
|
|
@@ -1055,7 +1008,7 @@ export class SqliteRemoteConnection {
|
|
|
1055
1008
|
}
|
|
1056
1009
|
;
|
|
1057
1010
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1058
|
-
logger.trace(sql
|
|
1011
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1059
1012
|
}
|
|
1060
1013
|
return new Promise(async (resolve, reject) => {
|
|
1061
1014
|
try {
|
|
@@ -1085,7 +1038,7 @@ export class SqliteRemoteConnection {
|
|
|
1085
1038
|
}
|
|
1086
1039
|
;
|
|
1087
1040
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1088
|
-
logger.trace(sql
|
|
1041
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1089
1042
|
}
|
|
1090
1043
|
return new Promise(async (resolve, reject) => {
|
|
1091
1044
|
try {
|
|
@@ -1115,7 +1068,7 @@ export class SqliteRemoteConnection {
|
|
|
1115
1068
|
}
|
|
1116
1069
|
;
|
|
1117
1070
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1118
|
-
logger.trace(sql
|
|
1071
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1119
1072
|
}
|
|
1120
1073
|
return new Promise(async (resolve, reject) => {
|
|
1121
1074
|
try {
|
|
@@ -1145,7 +1098,7 @@ export class SqliteRemoteConnection {
|
|
|
1145
1098
|
}
|
|
1146
1099
|
;
|
|
1147
1100
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1148
|
-
logger.trace(sql
|
|
1101
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1149
1102
|
}
|
|
1150
1103
|
return new Promise(async (resolve, reject) => {
|
|
1151
1104
|
try {
|
|
@@ -1175,7 +1128,7 @@ export class SqliteRemoteConnection {
|
|
|
1175
1128
|
}
|
|
1176
1129
|
;
|
|
1177
1130
|
if (globalThis[_GlobalSqlOption].log === 'trace') {
|
|
1178
|
-
logger.trace(sql
|
|
1131
|
+
logger.trace(`${sql}\n,${JSON.stringify(params ?? '')}`);
|
|
1179
1132
|
}
|
|
1180
1133
|
return new Promise(async (resolve, reject) => {
|
|
1181
1134
|
try {
|
|
@@ -1974,233 +1927,6 @@ const FieldFilter = (K, V, def, uuidColumn, option) => {
|
|
|
1974
1927
|
}
|
|
1975
1928
|
return [ret, V];
|
|
1976
1929
|
};
|
|
1977
|
-
const MYSQLCHARSET = `CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci`;
|
|
1978
|
-
const POSTGRESCHARSET = `COLLATE "pg_catalog"."default"`;
|
|
1979
|
-
export const Field = (config) => {
|
|
1980
|
-
config.type ?? (config.type = SqlType.varchar);
|
|
1981
|
-
return (object, propertyName) => {
|
|
1982
|
-
const field = config;
|
|
1983
|
-
field.P = propertyName;
|
|
1984
|
-
field.C = () => P2C(propertyName, globalThis[_Hump]);
|
|
1985
|
-
field.C2 = () => P2C(propertyName, globalThis[_Hump]);
|
|
1986
|
-
field.C3 = () => `${P2C(propertyName, globalThis[_Hump])} ${propertyName}`;
|
|
1987
|
-
const hasDef = field.hasOwnProperty('def') === true;
|
|
1988
|
-
switch (field.type) {
|
|
1989
|
-
case SqlType.tinyint: {
|
|
1990
|
-
field[DBType.Mysql] = () => `${field.C2()} tinyint ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
1991
|
-
field[DBType.Postgresql] = () => `${field.C2()} int2 ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
1992
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} integer`;
|
|
1993
|
-
break;
|
|
1994
|
-
}
|
|
1995
|
-
case SqlType.smallint: {
|
|
1996
|
-
field[DBType.Mysql] = () => `${field.C2()} smallint ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
1997
|
-
field[DBType.Postgresql] = () => `${field.C2()} int2 ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
1998
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} integer`;
|
|
1999
|
-
break;
|
|
2000
|
-
}
|
|
2001
|
-
case SqlType.mediumint: {
|
|
2002
|
-
field[DBType.Mysql] = () => `${field.C2()} smallint ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
2003
|
-
field[DBType.Postgresql] = () => `${field.C2()} int4 ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
2004
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} integer`;
|
|
2005
|
-
break;
|
|
2006
|
-
}
|
|
2007
|
-
case SqlType.int: {
|
|
2008
|
-
field[DBType.Mysql] = () => `${field.C2()} int ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
2009
|
-
field[DBType.Postgresql] = () => `${field.C2()} int4 ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT ${field.def}` : ''}`;
|
|
2010
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} integer`;
|
|
2011
|
-
break;
|
|
2012
|
-
}
|
|
2013
|
-
case SqlType.bigint: {
|
|
2014
|
-
field[DBType.Mysql] = () => `${field.C2()} bigint ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2015
|
-
field[DBType.Postgresql] = () => `${field.C2()} int8 ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2016
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} integer`;
|
|
2017
|
-
field.Data2SQL = (data) => BigInt(data ?? 0);
|
|
2018
|
-
break;
|
|
2019
|
-
}
|
|
2020
|
-
case SqlType.float: {
|
|
2021
|
-
field[DBType.Mysql] = () => `${field.C2()} float4(${config.length ?? 1}, ${config.scale ?? 2}) ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT '${field.def}'` : ''} `;
|
|
2022
|
-
field[DBType.Postgresql] = () => `${field.C2()} float4(${config.length ?? 1}, ${config.scale ?? 2}) ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT '${field.def}'` : ''} `;
|
|
2023
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} real`;
|
|
2024
|
-
break;
|
|
2025
|
-
}
|
|
2026
|
-
case SqlType.double: {
|
|
2027
|
-
field[DBType.Mysql] = () => `${field.C2()} double(${config.length ?? 1}, ${config.scale ?? 2}) ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT '${field.def}'` : ''} `;
|
|
2028
|
-
field[DBType.Postgresql] = () => `${field.C2()} float8(${config.length ?? 1}, ${config.scale ?? 2}) ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT '${field.def}'` : ''} `;
|
|
2029
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} real`;
|
|
2030
|
-
break;
|
|
2031
|
-
}
|
|
2032
|
-
case SqlType.decimal: {
|
|
2033
|
-
field[DBType.Mysql] = () => `${field.C2()} decimal(${config.length ?? 1}, ${config.scale ?? 2}) ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT '${field.def}'` : ''} `;
|
|
2034
|
-
field[DBType.Postgresql] = () => `${field.C2()} numeric(${config.length ?? 1}, ${config.scale ?? 2}) ${config.notNull === true ? 'NOT NULL' : ''} ${hasDef ? `DEFAULT '${field.def}'` : ''} `;
|
|
2035
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} real`;
|
|
2036
|
-
break;
|
|
2037
|
-
}
|
|
2038
|
-
case SqlType.longtext: {
|
|
2039
|
-
field[DBType.Mysql] = () => `${field.C2()} longtext ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2040
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2041
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2042
|
-
break;
|
|
2043
|
-
}
|
|
2044
|
-
case SqlType.mediumtext: {
|
|
2045
|
-
field[DBType.Mysql] = () => `${field.C2()} mediumtext ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2046
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2047
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2048
|
-
break;
|
|
2049
|
-
}
|
|
2050
|
-
case SqlType.text: {
|
|
2051
|
-
field[DBType.Mysql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2052
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2053
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2054
|
-
break;
|
|
2055
|
-
}
|
|
2056
|
-
case SqlType.date: {
|
|
2057
|
-
field[DBType.Mysql] = () => `${field.C2()} date ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2058
|
-
field[DBType.Postgresql] = () => `${field.C2()} date ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2059
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2060
|
-
field.Data2SQL = (data) => typeof data === 'string' ? new Date(data) : data;
|
|
2061
|
-
break;
|
|
2062
|
-
}
|
|
2063
|
-
case SqlType.time: {
|
|
2064
|
-
field[DBType.Mysql] = () => `${field.C2()} time ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2065
|
-
field[DBType.Postgresql] = () => `${field.C2()} time ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2066
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2067
|
-
field.Data2SQL = (data) => typeof data === 'string' ? new Date(data) : data;
|
|
2068
|
-
break;
|
|
2069
|
-
}
|
|
2070
|
-
case SqlType.year: {
|
|
2071
|
-
field[DBType.Mysql] = () => `${field.C2()} year ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2072
|
-
field[DBType.Postgresql] = () => `${field.C2()} int4 ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2073
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2074
|
-
field.Data2SQL = (data) => typeof data === 'string' ? new Date(data) : data;
|
|
2075
|
-
break;
|
|
2076
|
-
}
|
|
2077
|
-
case SqlType.datetime: {
|
|
2078
|
-
field[DBType.Mysql] = () => `${field.C2()} datetime ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2079
|
-
field[DBType.Postgresql] = () => `${field.C2()} timestamp ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2080
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2081
|
-
field.Data2SQL = (data) => typeof data === 'string' ? new Date(data) : data;
|
|
2082
|
-
break;
|
|
2083
|
-
}
|
|
2084
|
-
case SqlType.timestamp: {
|
|
2085
|
-
field[DBType.Mysql] = () => `${field.C2()} timestamp ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2086
|
-
field[DBType.Postgresql] = () => `${field.C2()} timestamp ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2087
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} integer`;
|
|
2088
|
-
field.Data2SQL = (data) => typeof data === 'string' ? +new Date(data) : data;
|
|
2089
|
-
break;
|
|
2090
|
-
}
|
|
2091
|
-
case SqlType.char: {
|
|
2092
|
-
field[DBType.Mysql] = () => `${field.C2()} char(${config.length ?? 1}) ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2093
|
-
field[DBType.Postgresql] = () => `${field.C2()} char(${config.length ?? 1}) ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2094
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2095
|
-
break;
|
|
2096
|
-
}
|
|
2097
|
-
case SqlType.varchar: {
|
|
2098
|
-
field[DBType.Mysql] = () => `${field.C2()} varchar(${config.length ?? 1}) ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2099
|
-
field[DBType.Postgresql] = () => `${field.C2()} varchar(${config.length ?? 1}) ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2100
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2101
|
-
break;
|
|
2102
|
-
}
|
|
2103
|
-
case SqlType.tinyblob: {
|
|
2104
|
-
field[DBType.Mysql] = () => `${field.C2()} tinyblob ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2105
|
-
field[DBType.Postgresql] = () => `${field.C2()} bytea ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2106
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2107
|
-
break;
|
|
2108
|
-
}
|
|
2109
|
-
case SqlType.tinytext: {
|
|
2110
|
-
field[DBType.Mysql] = () => `${field.C2()} tinytext ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2111
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2112
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2113
|
-
break;
|
|
2114
|
-
}
|
|
2115
|
-
case SqlType.blob: {
|
|
2116
|
-
field[DBType.Mysql] = () => `${field.C2()} binary ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2117
|
-
field[DBType.Postgresql] = () => `${field.C2()} bytea ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2118
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2119
|
-
break;
|
|
2120
|
-
}
|
|
2121
|
-
case SqlType.text: {
|
|
2122
|
-
field[DBType.Mysql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2123
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2124
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2125
|
-
break;
|
|
2126
|
-
}
|
|
2127
|
-
case SqlType.mediumblob: {
|
|
2128
|
-
field[DBType.Mysql] = () => `${field.C2()} mediumblob ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2129
|
-
field[DBType.Postgresql] = () => `${field.C2()} bytea ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2130
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2131
|
-
break;
|
|
2132
|
-
}
|
|
2133
|
-
case SqlType.mediumtext: {
|
|
2134
|
-
field[DBType.Mysql] = () => `${field.C2()} mediumtext ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2135
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2136
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2137
|
-
break;
|
|
2138
|
-
}
|
|
2139
|
-
case SqlType.longblob: {
|
|
2140
|
-
field[DBType.Mysql] = () => `${field.C2()} longblob ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2141
|
-
field[DBType.Postgresql] = () => `${field.C2()} bytea ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2142
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2143
|
-
break;
|
|
2144
|
-
}
|
|
2145
|
-
case SqlType.longtext: {
|
|
2146
|
-
field[DBType.Mysql] = () => `${field.C2()} longtext ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2147
|
-
field[DBType.Postgresql] = () => `${field.C2()} text ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2148
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2149
|
-
break;
|
|
2150
|
-
}
|
|
2151
|
-
case SqlType.json: {
|
|
2152
|
-
field[DBType.Mysql] = () => `${field.C2()} json ${config.notNull === true ? 'NOT NULL' : ''} ${MYSQLCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2153
|
-
field[DBType.Postgresql] = () => `${field.C2()} jsonb ${config.notNull === true ? 'NOT NULL' : ''} ${POSTGRESCHARSET} ${hasDef ? `DEFAULT '${field.def}'` : ''}`;
|
|
2154
|
-
field[DBType.SqliteRemote] = field[DBType.Sqlite] = () => `${field.C2()} text`;
|
|
2155
|
-
break;
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
;
|
|
2159
|
-
let __fields = Reflect.getMetadata(_fields, object);
|
|
2160
|
-
let __columns = Reflect.getMetadata(_columns, object);
|
|
2161
|
-
let __columnsNoId = Reflect.getMetadata(_columnsNoId, object);
|
|
2162
|
-
let __ids = Reflect.getMetadata(_ids, object);
|
|
2163
|
-
let __logicIds = Reflect.getMetadata(_logicIds, object);
|
|
2164
|
-
let __index = Reflect.getMetadata(_index, object);
|
|
2165
|
-
let __def = Reflect.getMetadata(_def, object);
|
|
2166
|
-
if (!__fields) {
|
|
2167
|
-
__fields = {};
|
|
2168
|
-
__columns = [];
|
|
2169
|
-
__columnsNoId = [];
|
|
2170
|
-
__ids = [];
|
|
2171
|
-
__index = [];
|
|
2172
|
-
__def = {};
|
|
2173
|
-
}
|
|
2174
|
-
__fields[propertyName] = field;
|
|
2175
|
-
__columns.push(propertyName);
|
|
2176
|
-
if (field.id === true) {
|
|
2177
|
-
__ids.push(propertyName);
|
|
2178
|
-
}
|
|
2179
|
-
else {
|
|
2180
|
-
__columnsNoId.push(propertyName);
|
|
2181
|
-
}
|
|
2182
|
-
if (field.logicId === true) {
|
|
2183
|
-
__logicIds.push(propertyName);
|
|
2184
|
-
}
|
|
2185
|
-
if (field.index === true) {
|
|
2186
|
-
__index.push(propertyName);
|
|
2187
|
-
}
|
|
2188
|
-
if (hasDef) {
|
|
2189
|
-
__def[propertyName] = field.def;
|
|
2190
|
-
}
|
|
2191
|
-
Reflect.defineMetadata(_fields, __fields, object);
|
|
2192
|
-
Reflect.defineMetadata(_columns, __columns, object);
|
|
2193
|
-
Reflect.defineMetadata(_columnsNoId, __columnsNoId, object);
|
|
2194
|
-
Reflect.defineMetadata(_ids, __ids, object);
|
|
2195
|
-
Reflect.defineMetadata(_logicIds, __logicIds, object);
|
|
2196
|
-
Reflect.defineMetadata(_index, __index, object);
|
|
2197
|
-
Reflect.defineMetadata(_def, __def, object);
|
|
2198
|
-
if (field.hasOwnProperty('logicDelete')) {
|
|
2199
|
-
Reflect.defineMetadata(_deleteState, field.logicDelete, object);
|
|
2200
|
-
Reflect.defineMetadata(_stateFileName, propertyName, object);
|
|
2201
|
-
}
|
|
2202
|
-
};
|
|
2203
|
-
};
|
|
2204
1930
|
const formatDialects = {
|
|
2205
1931
|
[DBType.Mysql]: mysql,
|
|
2206
1932
|
[DBType.Sqlite]: sqlite,
|
|
@@ -3064,27 +2790,7 @@ export class SqlService {
|
|
|
3064
2790
|
}
|
|
3065
2791
|
const _params = Object.assign({}, option.context, option.params);
|
|
3066
2792
|
option.sql ?? (option.sql = globalThis[_sqlCache].load(this._matchSqlid(option.sqlId), { ctx: option.context, isCount: option.isCount, ..._params }));
|
|
3067
|
-
const params =
|
|
3068
|
-
const sql = formatDialect(option.sql?.replace(/\:([A-Za-z0-9._]+)/g, (txt, key) => {
|
|
3069
|
-
let V = LGet(_params, key);
|
|
3070
|
-
if (V !== undefined) {
|
|
3071
|
-
params.push(V);
|
|
3072
|
-
return '?';
|
|
3073
|
-
}
|
|
3074
|
-
const _key = C2P(key);
|
|
3075
|
-
V = LGet(_params, _key);
|
|
3076
|
-
if (V !== undefined) {
|
|
3077
|
-
params.push(V);
|
|
3078
|
-
return '?';
|
|
3079
|
-
}
|
|
3080
|
-
const __key = P2C(key);
|
|
3081
|
-
V = LGet(_params, __key);
|
|
3082
|
-
if (V !== undefined) {
|
|
3083
|
-
params.push(V);
|
|
3084
|
-
return '?';
|
|
3085
|
-
}
|
|
3086
|
-
return txt;
|
|
3087
|
-
}), { dialect: formatDialects[option.dbType] });
|
|
2793
|
+
const { sql, params } = this._generSql(option.dbType, option.sql, _params);
|
|
3088
2794
|
if (option.sync === SyncMode.Sync) {
|
|
3089
2795
|
const result = option.conn.query(SyncMode.Sync, sql, params);
|
|
3090
2796
|
return this._select(option.selectResult, result, option.defValue, option.errorMsg, option.hump, option.mapper, option.mapperIfUndefined);
|
|
@@ -3105,27 +2811,7 @@ export class SqlService {
|
|
|
3105
2811
|
Throw.if(!option.sqlId && !option.sql, 'not found sql!');
|
|
3106
2812
|
const _params = Object.assign({}, option.context, option.params);
|
|
3107
2813
|
option.sql ?? (option.sql = globalThis[_sqlCache].load(this._matchSqlid(option.sqlId), { ctx: option.context, ..._params }));
|
|
3108
|
-
const params =
|
|
3109
|
-
const sql = formatDialect(option.sql?.replace(/\:(\w+)/g, (txt, key) => {
|
|
3110
|
-
let V = LGet(_params, key);
|
|
3111
|
-
if (V !== undefined) {
|
|
3112
|
-
params.push(V);
|
|
3113
|
-
return '?';
|
|
3114
|
-
}
|
|
3115
|
-
const _key = C2P(key);
|
|
3116
|
-
V = LGet(_params, _key);
|
|
3117
|
-
if (V !== undefined) {
|
|
3118
|
-
params.push(V);
|
|
3119
|
-
return '?';
|
|
3120
|
-
}
|
|
3121
|
-
const __key = P2C(key);
|
|
3122
|
-
V = LGet(_params, __key);
|
|
3123
|
-
if (V !== undefined) {
|
|
3124
|
-
params.push(V);
|
|
3125
|
-
return '?';
|
|
3126
|
-
}
|
|
3127
|
-
return txt;
|
|
3128
|
-
}), { dialect: formatDialects[option.dbType] });
|
|
2814
|
+
const { sql, params } = this._generSql(option.dbType, option.sql, _params);
|
|
3129
2815
|
if (option.sync === SyncMode.Sync) {
|
|
3130
2816
|
const result = option.conn.execute(SyncMode.Sync, sql, params);
|
|
3131
2817
|
return result.affectedRows;
|
|
@@ -3549,6 +3235,37 @@ export class SqlService {
|
|
|
3549
3235
|
else
|
|
3550
3236
|
return [`${this[_tableName]}.${sqlid}`, `${this[_className]}.${sqlid}`, `${this[_ClassName]}.${sqlid}`, `${this[_vueName]}.${sqlid}`];
|
|
3551
3237
|
}
|
|
3238
|
+
_setParam(v, ps) {
|
|
3239
|
+
if (v instanceof Array) {
|
|
3240
|
+
ps.push(...v);
|
|
3241
|
+
return v.map(i => '?').join(',');
|
|
3242
|
+
}
|
|
3243
|
+
else {
|
|
3244
|
+
ps.push(v);
|
|
3245
|
+
return '?';
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
_generSql(dbType, _sql, _params) {
|
|
3249
|
+
const params = [];
|
|
3250
|
+
const sql = formatDialect(_sql?.replace(/\:(\w+)/g, (txt, key) => {
|
|
3251
|
+
let V = LGet(_params, key);
|
|
3252
|
+
if (V !== undefined) {
|
|
3253
|
+
return this._setParam(V, params);
|
|
3254
|
+
}
|
|
3255
|
+
const _key = C2P(key);
|
|
3256
|
+
V = LGet(_params, _key);
|
|
3257
|
+
if (V !== undefined) {
|
|
3258
|
+
return this._setParam(V, params);
|
|
3259
|
+
}
|
|
3260
|
+
const __key = P2C(key);
|
|
3261
|
+
V = LGet(_params, __key);
|
|
3262
|
+
if (V !== undefined) {
|
|
3263
|
+
return this._setParam(V, params);
|
|
3264
|
+
}
|
|
3265
|
+
return txt;
|
|
3266
|
+
}), { dialect: formatDialects[dbType] });
|
|
3267
|
+
return { params, sql };
|
|
3268
|
+
}
|
|
3552
3269
|
}
|
|
3553
3270
|
__decorate([
|
|
3554
3271
|
P(),
|
|
@@ -3686,6 +3403,7 @@ class StreamQuery {
|
|
|
3686
3403
|
this.if_proceed = condition;
|
|
3687
3404
|
return this;
|
|
3688
3405
|
}
|
|
3406
|
+
eqs(keys, value, { paramName = '', skipEmptyString = true, breakExcuteIfSkip = false } = {}) { return this.__(keys, value, '=', { paramName, skipEmptyString, breakExcuteIfSkip }); }
|
|
3689
3407
|
eq(key, value, { paramName = '', skipEmptyString = true, breakExcuteIfSkip = false } = {}) { return this._(key, value, '=', { paramName, skipEmptyString, breakExcuteIfSkip }); }
|
|
3690
3408
|
eqT(t, { name: paramName = '', breakExcuteIfSkip = false } = {}) {
|
|
3691
3409
|
let exe = false;
|
|
@@ -4061,7 +3779,6 @@ class StreamQuery {
|
|
|
4061
3779
|
this._param[this._paramKeys[paramName]] = value;
|
|
4062
3780
|
}
|
|
4063
3781
|
else {
|
|
4064
|
-
paramName;
|
|
4065
3782
|
const pkey = `p${this._prefix}${this._index++}`;
|
|
4066
3783
|
this._wheres.push(`AND ${this[_fields][String(key)]?.C2()} ${not} ${op} :${pkey} `);
|
|
4067
3784
|
this._param[pkey] = value;
|
|
@@ -4071,6 +3788,28 @@ class StreamQuery {
|
|
|
4071
3788
|
}
|
|
4072
3789
|
return this;
|
|
4073
3790
|
}
|
|
3791
|
+
__(keys, value, op, { not = '', paramName = '', skipEmptyString = true, breakExcuteIfSkip = false } = {}) {
|
|
3792
|
+
if (value === null
|
|
3793
|
+
|| value === undefined
|
|
3794
|
+
|| (emptyString(`${value ?? ''}`) && skipEmptyString === true)) {
|
|
3795
|
+
if (breakExcuteIfSkip === true) {
|
|
3796
|
+
this.if_exec = false;
|
|
3797
|
+
}
|
|
3798
|
+
return this;
|
|
3799
|
+
}
|
|
3800
|
+
if (paramName !== undefined && this._paramKeys.hasOwnProperty(paramName)) {
|
|
3801
|
+
this._param[this._paramKeys[paramName]] = value;
|
|
3802
|
+
}
|
|
3803
|
+
else {
|
|
3804
|
+
const pkey = `p${this._prefix}${this._index++}`;
|
|
3805
|
+
this._wheres.push(`AND (${keys.map(key => `${this[_fields][String(key)]?.C2()} ${not} ${op} :${pkey} `).join(' OR ')})`);
|
|
3806
|
+
this._param[pkey] = value;
|
|
3807
|
+
if (paramName) {
|
|
3808
|
+
this._paramKeys[paramName] = pkey;
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
return this;
|
|
3812
|
+
}
|
|
4074
3813
|
_null(key, not = '') {
|
|
4075
3814
|
this._wheres.push(`AND ${this[_fields][String(key)]?.C2()} IS ${not} NULL`);
|
|
4076
3815
|
return this;
|
|
@@ -4242,6 +3981,12 @@ __decorate([
|
|
|
4242
3981
|
__metadata("design:paramtypes", [Boolean]),
|
|
4243
3982
|
__metadata("design:returntype", void 0)
|
|
4244
3983
|
], StreamQuery.prototype, "if", null);
|
|
3984
|
+
__decorate([
|
|
3985
|
+
IF_PROCEED(),
|
|
3986
|
+
__metadata("design:type", Function),
|
|
3987
|
+
__metadata("design:paramtypes", [Array, Object, Object]),
|
|
3988
|
+
__metadata("design:returntype", void 0)
|
|
3989
|
+
], StreamQuery.prototype, "eqs", null);
|
|
4245
3990
|
__decorate([
|
|
4246
3991
|
IF_PROCEED(),
|
|
4247
3992
|
__metadata("design:type", Function),
|