baja-lite 1.0.4 → 1.0.5
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/cjs/boot-remote.d.ts +2 -0
- package/cjs/boot-remote.js +35 -0
- package/cjs/boot.d.ts +2 -0
- package/cjs/boot.js +152 -0
- package/cjs/code.d.ts +1 -0
- package/cjs/code.js +345 -1
- package/cjs/convert-xml.d.ts +10 -0
- package/cjs/convert-xml.js +413 -0
- package/cjs/enum.d.ts +10 -0
- package/cjs/enum.js +32 -0
- package/cjs/error.js +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -0
- package/cjs/object.d.ts +7 -1
- package/cjs/object.js +36 -2
- package/cjs/sql.d.ts +405 -148
- package/cjs/sql.js +1229 -861
- package/cjs/sqlite.d.ts +38 -0
- package/cjs/sqlite.js +194 -0
- package/cjs/test-mysql.d.ts +1 -1
- package/cjs/test-mysql.js +72 -63
- package/cjs/test-sqlite.d.ts +1 -1
- package/cjs/test-sqlite.js +3 -1
- package/cjs/test-xml.d.ts +1 -0
- package/cjs/test-xml.js +75 -0
- package/es/boot-remote.d.ts +2 -0
- package/es/boot-remote.js +31 -0
- package/es/boot.d.ts +2 -0
- package/es/boot.js +125 -0
- package/es/code.d.ts +1 -0
- package/es/code.js +341 -2
- package/es/convert-xml.d.ts +10 -0
- package/es/convert-xml.js +409 -0
- package/es/enum.d.ts +10 -0
- package/es/enum.js +28 -0
- package/es/error.js +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/object.d.ts +7 -1
- package/es/object.js +28 -1
- package/es/sql.d.ts +405 -148
- package/es/sql.js +1099 -735
- package/es/sqlite.d.ts +38 -0
- package/es/sqlite.js +164 -0
- package/es/test-mysql.d.ts +1 -1
- package/es/test-mysql.js +72 -63
- package/es/test-sqlite.d.ts +1 -1
- package/es/test-sqlite.js +3 -1
- package/es/test-xml.d.ts +1 -0
- package/es/test-xml.js +70 -0
- package/package.json +10 -7
- package/src/boot-remote.ts +31 -0
- package/src/boot.ts +129 -0
- package/src/code.ts +326 -1
- package/src/convert-xml.ts +461 -0
- package/src/enum.ts +31 -0
- package/src/error.ts +1 -1
- package/src/index.ts +3 -1
- package/src/object.ts +47 -14
- package/src/sql.ts +1145 -787
- package/src/sqlite.ts +161 -0
- package/src/test-mysql.ts +72 -63
- package/src/test-sqlite.ts +3 -1
- package/src/test-xml.ts +70 -0
- package/cjs/constant.d.ts +0 -13
- package/cjs/constant.js +0 -19
- package/cjs/redis.d.ts +0 -0
- package/cjs/redis.js +0 -1
- package/es/constant.d.ts +0 -13
- package/es/constant.js +0 -16
- package/es/redis.d.ts +0 -0
- package/es/redis.js +0 -1
- package/src/constant.ts +0 -14
- package/src/redis.ts +0 -0
package/cjs/sql.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { XML } from './convert-xml';
|
|
2
2
|
declare const _daoDBName: unique symbol;
|
|
3
3
|
declare const _tableName: unique symbol;
|
|
4
|
+
declare const _className: unique symbol;
|
|
5
|
+
declare const _ClassName: unique symbol;
|
|
6
|
+
declare const _vueName: unique symbol;
|
|
4
7
|
declare const _ids: unique symbol;
|
|
5
8
|
declare const _columns: unique symbol;
|
|
6
9
|
declare const _columnsNoId: unique symbol;
|
|
@@ -10,12 +13,22 @@ declare const _deleteState: unique symbol;
|
|
|
10
13
|
declare const _transformer: unique symbol;
|
|
11
14
|
declare const _index: unique symbol;
|
|
12
15
|
declare const _def: unique symbol;
|
|
16
|
+
export declare const _sqlCache: unique symbol;
|
|
17
|
+
export declare const _dao: unique symbol;
|
|
18
|
+
export declare const _primaryDB: unique symbol;
|
|
13
19
|
declare const _dbType: unique symbol;
|
|
14
20
|
declare const _sqlite_version: unique symbol;
|
|
15
21
|
declare const _daoConnection: unique symbol;
|
|
16
22
|
declare const _inTransaction: unique symbol;
|
|
17
23
|
declare const _daoDB: unique symbol;
|
|
24
|
+
declare const _sqliteRemoteName: unique symbol;
|
|
18
25
|
declare const _SqlOption: unique symbol;
|
|
26
|
+
export declare const _Hump: unique symbol;
|
|
27
|
+
export declare const _GlobalSqlOption: unique symbol;
|
|
28
|
+
export declare const _EventBus: unique symbol;
|
|
29
|
+
export declare const _path: unique symbol;
|
|
30
|
+
export declare const _fs: unique symbol;
|
|
31
|
+
export declare const logger: import("pino").Logger<never>;
|
|
19
32
|
export declare enum DBType {
|
|
20
33
|
Mysql = 0,
|
|
21
34
|
Sqlite = 1,
|
|
@@ -132,6 +145,10 @@ export declare enum SqlType {
|
|
|
132
145
|
multipolygon = 32,
|
|
133
146
|
geometrycollection = 33
|
|
134
147
|
}
|
|
148
|
+
export declare enum ColumnMode {
|
|
149
|
+
NONE = 0,
|
|
150
|
+
HUMP = 1
|
|
151
|
+
}
|
|
135
152
|
export declare const SqliteMemory = ":memory:";
|
|
136
153
|
interface MethodOption {
|
|
137
154
|
tableName?: string;
|
|
@@ -144,6 +161,12 @@ interface MethodOption {
|
|
|
144
161
|
/** 调用时,仅在开启事务时需要主动传入,传入方式: */
|
|
145
162
|
conn?: Connection | null;
|
|
146
163
|
}
|
|
164
|
+
export declare const _defOption: {
|
|
165
|
+
maxDeal: number;
|
|
166
|
+
skipUndefined: boolean;
|
|
167
|
+
skipNull: boolean;
|
|
168
|
+
skipEmptyString: boolean;
|
|
169
|
+
};
|
|
147
170
|
/**
|
|
148
171
|
数据服务注解
|
|
149
172
|
*/
|
|
@@ -184,7 +207,7 @@ interface ServiceOption {
|
|
|
184
207
|
```
|
|
185
208
|
可以继承该接口来约束格式
|
|
186
209
|
*/
|
|
187
|
-
interface
|
|
210
|
+
export interface GlobalSqlOption2 {
|
|
188
211
|
/** 增改忽略Undefined */
|
|
189
212
|
skipUndefined?: boolean;
|
|
190
213
|
/** 增改忽略NULL */
|
|
@@ -193,6 +216,51 @@ interface GlobalSqlOption {
|
|
|
193
216
|
skipEmptyString?: boolean;
|
|
194
217
|
/** 批量增改时,每次执行最多处理的记录数量 */
|
|
195
218
|
maxDeal?: number;
|
|
219
|
+
SqliteRemote?: {
|
|
220
|
+
/**
|
|
221
|
+
## 单一数据源
|
|
222
|
+
```
|
|
223
|
+
db: 'd:/1.db'
|
|
224
|
+
```
|
|
225
|
+
## 多数据源:传入多个Mysql2的连接配置
|
|
226
|
+
```
|
|
227
|
+
db: {
|
|
228
|
+
db1: 'd:/1.db',
|
|
229
|
+
db2: 'd:/2.db'
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
不支持 `SqliteMemory`
|
|
233
|
+
*/
|
|
234
|
+
db: Record<string, string> | string;
|
|
235
|
+
/** 远程SQLITE接口实现,适用于Electron, 采用Ipc 的handel机制实现 */
|
|
236
|
+
service: SqliteRemoteInterface;
|
|
237
|
+
};
|
|
238
|
+
/** 日志等级 */
|
|
239
|
+
log?: 'trace' | 'debug' | 'info' | 'warn';
|
|
240
|
+
/**
|
|
241
|
+
作用与sqlDir类似,不同在于sqlMap`不需要`目录,而是直接指定一个sqlModel对象,对象的格式和sqlDir的文件内容一样。
|
|
242
|
+
** 适用于简单使用
|
|
243
|
+
*/
|
|
244
|
+
sqlMap?: SqlModel;
|
|
245
|
+
/**
|
|
246
|
+
作用与sqlFnDir类似,不同在于sqlFNMap`不需要`目录,而是直接指定一个 Record<string, string>,对象的格式和sqlFnDir的文件内容一样。
|
|
247
|
+
** 适用于简单使用
|
|
248
|
+
*/
|
|
249
|
+
sqlFNMap?: Record<string, string>;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
# 全局行为配置文件
|
|
253
|
+
MYSQL编码: 'utf8mb4', utf8mb4_general_ci'
|
|
254
|
+
### `sqlDir?: string;` 数据库查询语句存放目录.存放格式为 export.default 的js、ts, 存放内容满足格式:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
interface SqlModel {
|
|
258
|
+
[key: string]: string | ((params: { [k: string]: any }, context: any, isCount?: boolean) => string)
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
可以继承该接口来约束格式
|
|
262
|
+
*/
|
|
263
|
+
export interface GlobalSqlOption extends GlobalSqlOption2 {
|
|
196
264
|
/**
|
|
197
265
|
初始化MYSQL链接 支持多数据源
|
|
198
266
|
## 单一数据源: 直接传入Mysql2的连接配置
|
|
@@ -234,27 +302,6 @@ interface GlobalSqlOption {
|
|
|
234
302
|
路径 = `SqliteMemory` 将创建内存库
|
|
235
303
|
*/
|
|
236
304
|
Sqlite?: Record<string, string> | string;
|
|
237
|
-
SqliteRemote?: {
|
|
238
|
-
/**
|
|
239
|
-
## 单一数据源
|
|
240
|
-
```
|
|
241
|
-
db: 'd:/1.db'
|
|
242
|
-
```
|
|
243
|
-
## 多数据源:传入多个Mysql2的连接配置
|
|
244
|
-
```
|
|
245
|
-
db: {
|
|
246
|
-
db1: 'd:/1.db',
|
|
247
|
-
db2: 'd:/2.db'
|
|
248
|
-
}
|
|
249
|
-
```
|
|
250
|
-
不支持 `SqliteMemory`
|
|
251
|
-
*/
|
|
252
|
-
db: Record<string, string> | string;
|
|
253
|
-
/** 远程SQLITE接口实现,适用于Electron, 采用Ipc 的handel机制实现 */
|
|
254
|
-
service: SqliteRemoteInterface;
|
|
255
|
-
};
|
|
256
|
-
/** 日志等级 */
|
|
257
|
-
log?: 'trace' | 'debug' | 'info' | 'warn';
|
|
258
305
|
/**
|
|
259
306
|
## 日志文件存放路径,该目录下文件名是模块名,例如有一个文件名为 `user.js`,内容为:
|
|
260
307
|
```
|
|
@@ -287,21 +334,11 @@ interface GlobalSqlOption {
|
|
|
287
334
|
## 也支持.mu文件,格式略
|
|
288
335
|
*/
|
|
289
336
|
sqlDir?: string;
|
|
290
|
-
/**
|
|
291
|
-
作用与sqlDir类似,不同在于sqlMap`不需要`目录,而是直接指定一个sqlModel对象,对象的格式和sqlDir的文件内容一样。
|
|
292
|
-
** 适用于简单使用
|
|
293
|
-
*/
|
|
294
|
-
sqlMap?: SqlModel;
|
|
295
337
|
/**
|
|
296
338
|
## [mustache](https://mustache.github.io/) 编译时的[模板](https://github.com/janl/mustache.js#:~:text=requires%20only%20this%3A-,%7B%7B%3E%20next_more%7D%7D,-Why%3F%20Because%20the)
|
|
297
339
|
** 文件名就是模板名
|
|
298
340
|
*/
|
|
299
341
|
sqlFNDir?: string;
|
|
300
|
-
/**
|
|
301
|
-
作用与sqlFnDir类似,不同在于sqlFNMap`不需要`目录,而是直接指定一个 Record<string, string>,对象的格式和sqlFnDir的文件内容一样。
|
|
302
|
-
** 适用于简单使用
|
|
303
|
-
*/
|
|
304
|
-
sqlFNMap?: Record<string, string>;
|
|
305
342
|
/**
|
|
306
343
|
[REDIS初始化文档](https://github.com/redis/ioredis?tab=readme-ov-file#:~:text=connect%20to%20by%3A-,new%20Redis()%3B,-//%20Connect%20to%20127.0.0.1)
|
|
307
344
|
```
|
|
@@ -326,17 +363,56 @@ interface GlobalSqlOption {
|
|
|
326
363
|
```
|
|
327
364
|
*/
|
|
328
365
|
Redis?: Record<string, Record<string, any>> | Record<string, any>;
|
|
366
|
+
/**
|
|
367
|
+
* `列名与属性映射` 是否自动将下划线转为驼峰,默认NONE,即不转.
|
|
368
|
+
* 当设置为columnMode.HUMP时,切记将代码生成器中属性名称改对
|
|
369
|
+
* # 自定义sql查询时,无法自动转换哦,可使用标签转换:
|
|
370
|
+
*```
|
|
371
|
+
SELECT
|
|
372
|
+
* {{#hump}} seller_sku2, seller_sku {{/hump}}
|
|
373
|
+
* ```
|
|
374
|
+
* 转换为
|
|
375
|
+
*```
|
|
376
|
+
SELECT
|
|
377
|
+
* {{#hump}} seller_sku2 sellerSku2, seller_sku sellerSku {{/hump}}
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
columnMode?: ColumnMode;
|
|
329
381
|
}
|
|
330
382
|
interface FieldOption extends Object {
|
|
331
383
|
type?: SqlType;
|
|
332
|
-
|
|
384
|
+
/** @deprecated 属性名称:TS注解不需要,JS手动注入需要 */
|
|
385
|
+
P?: string;
|
|
333
386
|
length?: number;
|
|
334
387
|
scale?: number;
|
|
335
388
|
def?: any;
|
|
336
389
|
index?: boolean;
|
|
337
390
|
id?: boolean;
|
|
338
|
-
logicDelete?: string;
|
|
391
|
+
logicDelete?: string | number;
|
|
392
|
+
/** 仅在生成 表时有效 */
|
|
339
393
|
notNull?: boolean;
|
|
394
|
+
comment?: string;
|
|
395
|
+
/** sqlite 无效,与UUID只能有一个 */
|
|
396
|
+
uuidShort?: boolean;
|
|
397
|
+
/** 与uuidShort只能有一个 */
|
|
398
|
+
uuid?: boolean;
|
|
399
|
+
}
|
|
400
|
+
interface AField extends FieldOption {
|
|
401
|
+
/** 安全列名 */
|
|
402
|
+
C2: () => string;
|
|
403
|
+
/** @deprecated 数据列名称 */
|
|
404
|
+
C?: () => string;
|
|
405
|
+
/** 查询用:b_id bId */
|
|
406
|
+
C3: () => string;
|
|
407
|
+
[DBType.Mysql]: () => string;
|
|
408
|
+
[DBType.Sqlite]: () => string;
|
|
409
|
+
[DBType.SqliteRemote]: () => string;
|
|
410
|
+
}
|
|
411
|
+
export interface PageQuery<L> {
|
|
412
|
+
sum?: Record<string, number>;
|
|
413
|
+
total?: number;
|
|
414
|
+
size?: number;
|
|
415
|
+
records?: L[];
|
|
340
416
|
}
|
|
341
417
|
/** sqlite electron服务端需要支持的接口 */
|
|
342
418
|
export interface SqliteRemoteInterface {
|
|
@@ -344,13 +420,13 @@ export interface SqliteRemoteInterface {
|
|
|
344
420
|
affectedRows: number;
|
|
345
421
|
insertId: bigint;
|
|
346
422
|
}>;
|
|
347
|
-
pluck<One_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<One_Row_Many_Column |
|
|
348
|
-
get<One_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<One_Row_Many_Column |
|
|
423
|
+
pluck<One_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<One_Row_Many_Column | null>;
|
|
424
|
+
get<One_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<One_Row_Many_Column | null>;
|
|
349
425
|
raw<Many_Row_One_Column = any>(dbName: string, sql?: string, params?: any): Promise<Many_Row_One_Column[]>;
|
|
350
426
|
query<Many_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<Many_Row_Many_Column[]>;
|
|
351
427
|
initDB(dbName: string): Promise<void>;
|
|
352
|
-
|
|
353
|
-
restore(dbName: string,
|
|
428
|
+
export(dbName: string): Promise<void>;
|
|
429
|
+
restore(dbName: string, fromName: string): Promise<void>;
|
|
354
430
|
}
|
|
355
431
|
interface Connection {
|
|
356
432
|
[_daoConnection]: any;
|
|
@@ -393,6 +469,79 @@ interface Dao {
|
|
|
393
469
|
restore(sync: SyncMode.Sync, name: string): void;
|
|
394
470
|
restore(sync: SyncMode.Async, name: string): Promise<void>;
|
|
395
471
|
}
|
|
472
|
+
export declare class Mysql implements Dao {
|
|
473
|
+
[_daoDB]: any;
|
|
474
|
+
constructor(pool: any);
|
|
475
|
+
createConnection(sync: SyncMode.Sync): Connection | null;
|
|
476
|
+
createConnection(sync: SyncMode.Async): Promise<Connection | null>;
|
|
477
|
+
transaction<T = any>(sync: SyncMode.Sync, fn: (conn: Connection) => T, conn?: Connection | null): T | null;
|
|
478
|
+
transaction<T = any>(sync: SyncMode.Async, fn: (conn: Connection) => Promise<T>, conn?: Connection | null): Promise<T | null>;
|
|
479
|
+
close(sync: SyncMode.Sync): void;
|
|
480
|
+
close(sync: SyncMode.Async): Promise<void>;
|
|
481
|
+
backup(sync: SyncMode.Sync, name: string): void;
|
|
482
|
+
backup(sync: SyncMode.Async, name: string): Promise<void>;
|
|
483
|
+
remove(sync: SyncMode.Sync): void;
|
|
484
|
+
remove(sync: SyncMode.Async): Promise<void>;
|
|
485
|
+
restore(sync: SyncMode.Sync, name: string): void;
|
|
486
|
+
restore(sync: SyncMode.Async, name: string): Promise<void>;
|
|
487
|
+
}
|
|
488
|
+
export declare class Sqlite implements Dao {
|
|
489
|
+
[_daoDB]: any;
|
|
490
|
+
constructor(db: any);
|
|
491
|
+
createConnection(sync: SyncMode.Sync): Connection | null;
|
|
492
|
+
createConnection(sync: SyncMode.Async): Promise<Connection | null>;
|
|
493
|
+
transaction<T = any>(sync: SyncMode.Sync, fn: (conn: Connection) => T, conn?: Connection | null): T | null;
|
|
494
|
+
transaction<T = any>(sync: SyncMode.Async, fn: (conn: Connection) => Promise<T>, conn?: Connection | null): Promise<T | null>;
|
|
495
|
+
close(sync: SyncMode.Sync): void;
|
|
496
|
+
close(sync: SyncMode.Async): Promise<void>;
|
|
497
|
+
backup(sync: SyncMode.Sync, name: string): void;
|
|
498
|
+
backup(sync: SyncMode.Async, name: string): Promise<void>;
|
|
499
|
+
remove(sync: SyncMode.Sync): void;
|
|
500
|
+
remove(sync: SyncMode.Async): Promise<void>;
|
|
501
|
+
restore(sync: SyncMode.Sync, name: string): void;
|
|
502
|
+
restore(sync: SyncMode.Async, name: string): Promise<void>;
|
|
503
|
+
}
|
|
504
|
+
export declare class SqliteRemoteConnection implements Connection {
|
|
505
|
+
[_daoConnection]: SqliteRemoteInterface;
|
|
506
|
+
[_sqliteRemoteName]: string;
|
|
507
|
+
[_inTransaction]: boolean;
|
|
508
|
+
constructor(conn: SqliteRemoteInterface, name: string);
|
|
509
|
+
execute(sync: SyncMode.Sync, sql?: string, params?: any): {
|
|
510
|
+
affectedRows: number;
|
|
511
|
+
insertId: bigint;
|
|
512
|
+
};
|
|
513
|
+
execute(sync: SyncMode.Async, sql?: string, params?: any): Promise<{
|
|
514
|
+
affectedRows: number;
|
|
515
|
+
insertId: bigint;
|
|
516
|
+
}>;
|
|
517
|
+
pluck<T = any>(sync: SyncMode.Sync, sql?: string, params?: any): T | null;
|
|
518
|
+
pluck<T = any>(sync: SyncMode.Async, sql?: string, params?: any): Promise<T | null>;
|
|
519
|
+
get<T = any>(sync: SyncMode.Sync, sql?: string, params?: any): T | null;
|
|
520
|
+
get<T = any>(sync: SyncMode.Async, sql?: string, params?: any): Promise<T | null>;
|
|
521
|
+
raw<T = any>(sync: SyncMode.Sync, sql?: string, params?: any): T[];
|
|
522
|
+
raw<T = any>(sync: SyncMode.Async, sql?: string, params?: any): Promise<T[]>;
|
|
523
|
+
query<T = any>(sync: SyncMode.Sync, sql?: string, params?: any): T[];
|
|
524
|
+
query<T = any>(sync: SyncMode.Async, sql?: string, params?: any): Promise<T[]>;
|
|
525
|
+
realse(sync: SyncMode.Sync): void;
|
|
526
|
+
realse(sync: SyncMode.Async): Promise<void>;
|
|
527
|
+
}
|
|
528
|
+
export declare class SqliteRemote implements Dao {
|
|
529
|
+
[_sqliteRemoteName]: string;
|
|
530
|
+
[_daoDB]: SqliteRemoteInterface;
|
|
531
|
+
constructor(db: SqliteRemoteInterface, name: string);
|
|
532
|
+
createConnection(sync: SyncMode.Sync): Connection | null;
|
|
533
|
+
createConnection(sync: SyncMode.Async): Promise<Connection | null>;
|
|
534
|
+
transaction<T = any>(sync: SyncMode.Sync, fn: (conn: Connection) => T, conn?: Connection | null): T | null;
|
|
535
|
+
transaction<T = any>(sync: SyncMode.Async, fn: (conn: Connection) => Promise<T>, conn?: Connection | null): Promise<T | null>;
|
|
536
|
+
close(sync: SyncMode.Sync): void;
|
|
537
|
+
close(sync: SyncMode.Async): Promise<void>;
|
|
538
|
+
backup(sync: SyncMode.Sync, name: string): void;
|
|
539
|
+
backup(sync: SyncMode.Async, name: string): Promise<void>;
|
|
540
|
+
remove(sync: SyncMode.Sync): void;
|
|
541
|
+
remove(sync: SyncMode.Async): Promise<void>;
|
|
542
|
+
restore(sync: SyncMode.Sync, name: string): void;
|
|
543
|
+
restore(sync: SyncMode.Async, name: string): Promise<void>;
|
|
544
|
+
}
|
|
396
545
|
export type SqlModel = Record<string, string | ((options: {
|
|
397
546
|
ctx: any;
|
|
398
547
|
isCount?: boolean;
|
|
@@ -401,11 +550,33 @@ export type SqlModel = Record<string, string | ((options: {
|
|
|
401
550
|
limitEnd?: number;
|
|
402
551
|
orderBy?: string;
|
|
403
552
|
[k: string]: any;
|
|
404
|
-
}) => string)>;
|
|
553
|
+
}) => string) | XML[]>;
|
|
554
|
+
export declare class SqlCache {
|
|
555
|
+
private sqlMap;
|
|
556
|
+
private sqlFNMap;
|
|
557
|
+
init(options: {
|
|
558
|
+
sqlMap?: SqlModel;
|
|
559
|
+
sqlDir?: string;
|
|
560
|
+
sqlFNMap?: Record<string, string>;
|
|
561
|
+
sqlFNDir?: string;
|
|
562
|
+
}): Promise<void>;
|
|
563
|
+
load(sqlids: string[], options: {
|
|
564
|
+
ctx: any;
|
|
565
|
+
isCount?: boolean;
|
|
566
|
+
isSum?: boolean;
|
|
567
|
+
limitStart?: number;
|
|
568
|
+
limitEnd?: number;
|
|
569
|
+
orderBy?: string;
|
|
570
|
+
[k: string]: any;
|
|
571
|
+
}): string;
|
|
572
|
+
}
|
|
405
573
|
export declare const Field: (config: FieldOption) => (object: object, propertyName: string) => void;
|
|
406
574
|
export declare const DB: (config: ServiceOption) => <C extends new (...args: any[]) => {}>(constructor: C) => {
|
|
407
575
|
new (...args: any[]): {
|
|
408
576
|
[_tableName]: string | undefined;
|
|
577
|
+
[_className]: string | undefined;
|
|
578
|
+
[_ClassName]: string | undefined;
|
|
579
|
+
[_vueName]: string | undefined;
|
|
409
580
|
[_daoDBName]: string | undefined;
|
|
410
581
|
[_dbType]: DBType;
|
|
411
582
|
[_sqlite_version]: string | undefined;
|
|
@@ -426,8 +597,11 @@ export declare const DB: (config: ServiceOption) => <C extends new (...args: any
|
|
|
426
597
|
[_transformer]: <L extends Object>(data: L, option?: MethodOption & {
|
|
427
598
|
finalColumns?: Set<string>;
|
|
428
599
|
tempColumns?: Array<string>;
|
|
429
|
-
|
|
600
|
+
insert?: boolean;
|
|
430
601
|
skipId?: boolean;
|
|
602
|
+
skipNull?: boolean;
|
|
603
|
+
skipUndefined?: boolean;
|
|
604
|
+
skipEmptyString?: boolean;
|
|
431
605
|
onFieldExists?: (K: string, V: any) => void;
|
|
432
606
|
}) => any;
|
|
433
607
|
};
|
|
@@ -470,6 +644,9 @@ export declare function DeclareService(clz: any, config: ServiceOption): any;
|
|
|
470
644
|
*/
|
|
471
645
|
export declare class SqlService<T extends object> {
|
|
472
646
|
private [_tableName]?;
|
|
647
|
+
private [_className]?;
|
|
648
|
+
private [_ClassName]?;
|
|
649
|
+
private [_vueName]?;
|
|
473
650
|
private [_daoDBName]?;
|
|
474
651
|
private [_ids]?;
|
|
475
652
|
private [_fields]?;
|
|
@@ -482,7 +659,15 @@ export declare class SqlService<T extends object> {
|
|
|
482
659
|
private [_sqlite_version]?;
|
|
483
660
|
private [_index]?;
|
|
484
661
|
private [_def]?;
|
|
485
|
-
|
|
662
|
+
[_transformer]?: <L = T>(data: Partial<L>, option?: MethodOption & {
|
|
663
|
+
finalColumns?: Set<string>;
|
|
664
|
+
insert?: boolean;
|
|
665
|
+
skipId?: boolean;
|
|
666
|
+
skipNull?: boolean;
|
|
667
|
+
skipUndefined?: boolean;
|
|
668
|
+
skipEmptyString?: boolean;
|
|
669
|
+
onFieldExists?: (K: string, V: any) => void;
|
|
670
|
+
}) => Partial<T>;
|
|
486
671
|
private _insert;
|
|
487
672
|
/**
|
|
488
673
|
0. `sync`: 同步(sqlite)或者异步(mysql、remote),影响返回值类型,默认 `异步`
|
|
@@ -505,6 +690,7 @@ export declare class SqlService<T extends object> {
|
|
|
505
690
|
2. `insertIfNotExists`: 通过主键或者existConditionOtherThanIds字段判断数据是否存在,不存在才插入,存在则不执行
|
|
506
691
|
3. `replace`: 只支持用主键判断, 存在更新, 不存在插入
|
|
507
692
|
11. `existConditionOtherThanIds`: insertIfNotExists时判断同一记录的字段名称,默认情况下按照ID判断,设置existConditionOtherThanIds后,不用id
|
|
693
|
+
12. `replaceWithDef` replace时,是否带入默认值? 默认true
|
|
508
694
|
### 返回值是最后一次插入的主键ID,对于自增ID表适用
|
|
509
695
|
1. 如果主键是自增批量操作,且期望返回所有记录的ID,那么需要设置 `option 中的 every = true`,此时效率降低
|
|
510
696
|
* @param {{[P in keyof T]?: T[P]}} data
|
|
@@ -522,6 +708,7 @@ export declare class SqlService<T extends object> {
|
|
|
522
708
|
skipNull?: boolean;
|
|
523
709
|
skipEmptyString?: boolean;
|
|
524
710
|
maxDeal?: number;
|
|
711
|
+
replaceWithDef?: boolean;
|
|
525
712
|
}): Promise<bigint>;
|
|
526
713
|
insert(option: MethodOption & {
|
|
527
714
|
data: Partial<T>[];
|
|
@@ -534,6 +721,7 @@ export declare class SqlService<T extends object> {
|
|
|
534
721
|
skipNull?: boolean;
|
|
535
722
|
skipEmptyString?: boolean;
|
|
536
723
|
maxDeal?: number;
|
|
724
|
+
replaceWithDef?: boolean;
|
|
537
725
|
}): Promise<bigint[]>;
|
|
538
726
|
insert(option: MethodOption & {
|
|
539
727
|
data: Partial<T>;
|
|
@@ -546,6 +734,7 @@ export declare class SqlService<T extends object> {
|
|
|
546
734
|
skipNull?: boolean;
|
|
547
735
|
skipEmptyString?: boolean;
|
|
548
736
|
maxDeal?: number;
|
|
737
|
+
replaceWithDef?: boolean;
|
|
549
738
|
}): bigint;
|
|
550
739
|
insert(option: MethodOption & {
|
|
551
740
|
data: Partial<T>[];
|
|
@@ -558,6 +747,7 @@ export declare class SqlService<T extends object> {
|
|
|
558
747
|
skipNull?: boolean;
|
|
559
748
|
skipEmptyString?: boolean;
|
|
560
749
|
maxDeal?: number;
|
|
750
|
+
replaceWithDef?: boolean;
|
|
561
751
|
}): bigint[];
|
|
562
752
|
private _update;
|
|
563
753
|
/**
|
|
@@ -650,110 +840,146 @@ export declare class SqlService<T extends object> {
|
|
|
650
840
|
8. `dao`: 永远不需要传入该值
|
|
651
841
|
|
|
652
842
|
*/
|
|
653
|
-
template(option: MethodOption & {
|
|
843
|
+
template<L = T>(option: MethodOption & {
|
|
654
844
|
templateResult?: TemplateResult.AssertOne;
|
|
655
845
|
id?: string | number | Array<string | number>;
|
|
656
|
-
where?: Partial<
|
|
846
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
847
|
+
skipUndefined?: boolean;
|
|
848
|
+
skipNull?: boolean;
|
|
849
|
+
skipEmptyString?: boolean;
|
|
657
850
|
mode?: SelectMode;
|
|
658
851
|
error?: string;
|
|
659
|
-
columns?: (keyof
|
|
660
|
-
}): Promise<
|
|
661
|
-
template(option: MethodOption & {
|
|
852
|
+
columns?: (keyof L)[];
|
|
853
|
+
}): Promise<L>;
|
|
854
|
+
template<L = T>(option: MethodOption & {
|
|
662
855
|
sync: SyncMode.Sync;
|
|
663
856
|
templateResult?: TemplateResult.AssertOne;
|
|
664
857
|
id?: string | number | Array<string | number>;
|
|
665
|
-
where?: Partial<
|
|
858
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
859
|
+
skipUndefined?: boolean;
|
|
860
|
+
skipNull?: boolean;
|
|
861
|
+
skipEmptyString?: boolean;
|
|
666
862
|
mode?: SelectMode;
|
|
667
863
|
error?: string;
|
|
668
|
-
columns?: (keyof
|
|
669
|
-
}):
|
|
670
|
-
template(option: MethodOption & {
|
|
864
|
+
columns?: (keyof L)[];
|
|
865
|
+
}): L;
|
|
866
|
+
template<L = T>(option: MethodOption & {
|
|
671
867
|
sync: SyncMode.Async;
|
|
672
868
|
templateResult?: TemplateResult.AssertOne;
|
|
673
869
|
id?: string | number | Array<string | number>;
|
|
674
|
-
where?: Partial<
|
|
870
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
871
|
+
skipUndefined?: boolean;
|
|
872
|
+
skipNull?: boolean;
|
|
873
|
+
skipEmptyString?: boolean;
|
|
675
874
|
mode?: SelectMode;
|
|
676
875
|
error?: string;
|
|
677
|
-
columns?: (keyof
|
|
678
|
-
}): Promise<
|
|
679
|
-
template(option: MethodOption & {
|
|
876
|
+
columns?: (keyof L)[];
|
|
877
|
+
}): Promise<L>;
|
|
878
|
+
template<L = T>(option: MethodOption & {
|
|
680
879
|
templateResult: TemplateResult.Count;
|
|
681
880
|
id?: string | number | Array<string | number>;
|
|
682
|
-
where?: Partial<
|
|
881
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
882
|
+
skipUndefined?: boolean;
|
|
883
|
+
skipNull?: boolean;
|
|
884
|
+
skipEmptyString?: boolean;
|
|
683
885
|
mode?: SelectMode;
|
|
684
886
|
error?: string;
|
|
685
|
-
columns?: (keyof
|
|
887
|
+
columns?: (keyof L)[];
|
|
686
888
|
}): Promise<number>;
|
|
687
|
-
template(option: MethodOption & {
|
|
889
|
+
template<L = T>(option: MethodOption & {
|
|
688
890
|
sync: SyncMode.Sync;
|
|
689
891
|
templateResult: TemplateResult.Count;
|
|
690
892
|
id?: string | number | Array<string | number>;
|
|
691
|
-
where?: Partial<
|
|
893
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
894
|
+
skipUndefined?: boolean;
|
|
895
|
+
skipNull?: boolean;
|
|
896
|
+
skipEmptyString?: boolean;
|
|
692
897
|
mode?: SelectMode;
|
|
693
898
|
error?: string;
|
|
694
|
-
columns?: (keyof
|
|
899
|
+
columns?: (keyof L)[];
|
|
695
900
|
}): number;
|
|
696
|
-
template(option: MethodOption & {
|
|
901
|
+
template<L = T>(option: MethodOption & {
|
|
697
902
|
sync: SyncMode.Async;
|
|
698
903
|
templateResult: TemplateResult.Count;
|
|
699
904
|
id?: string | number | Array<string | number>;
|
|
700
|
-
where?: Partial<
|
|
905
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
906
|
+
skipUndefined?: boolean;
|
|
907
|
+
skipNull?: boolean;
|
|
908
|
+
skipEmptyString?: boolean;
|
|
701
909
|
mode?: SelectMode;
|
|
702
910
|
error?: string;
|
|
703
|
-
columns?: (keyof
|
|
911
|
+
columns?: (keyof L)[];
|
|
704
912
|
}): Promise<number>;
|
|
705
|
-
template(option: MethodOption & {
|
|
913
|
+
template<L = T>(option: MethodOption & {
|
|
706
914
|
templateResult: TemplateResult.NotSureOne;
|
|
707
915
|
id?: string | number | Array<string | number>;
|
|
708
|
-
where?: Partial<
|
|
916
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
917
|
+
skipUndefined?: boolean;
|
|
918
|
+
skipNull?: boolean;
|
|
919
|
+
skipEmptyString?: boolean;
|
|
709
920
|
mode?: SelectMode;
|
|
710
921
|
error?: string;
|
|
711
|
-
columns?: (keyof
|
|
712
|
-
}): Promise<
|
|
713
|
-
template(option: MethodOption & {
|
|
922
|
+
columns?: (keyof L)[];
|
|
923
|
+
}): Promise<L | null>;
|
|
924
|
+
template<L = T>(option: MethodOption & {
|
|
714
925
|
sync: SyncMode.Sync;
|
|
715
926
|
templateResult: TemplateResult.NotSureOne;
|
|
716
927
|
id?: string | number | Array<string | number>;
|
|
717
|
-
where?: Partial<
|
|
928
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
929
|
+
skipUndefined?: boolean;
|
|
930
|
+
skipNull?: boolean;
|
|
931
|
+
skipEmptyString?: boolean;
|
|
718
932
|
mode?: SelectMode;
|
|
719
933
|
error?: string;
|
|
720
|
-
columns?: (keyof
|
|
721
|
-
}):
|
|
722
|
-
template(option: MethodOption & {
|
|
934
|
+
columns?: (keyof L)[];
|
|
935
|
+
}): L | null;
|
|
936
|
+
template<L = T>(option: MethodOption & {
|
|
723
937
|
sync: SyncMode.Async;
|
|
724
938
|
templateResult: TemplateResult.NotSureOne;
|
|
725
939
|
id?: string | number | Array<string | number>;
|
|
726
|
-
where?: Partial<
|
|
940
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
941
|
+
skipUndefined?: boolean;
|
|
942
|
+
skipNull?: boolean;
|
|
943
|
+
skipEmptyString?: boolean;
|
|
727
944
|
mode?: SelectMode;
|
|
728
945
|
error?: string;
|
|
729
|
-
columns?: (keyof
|
|
730
|
-
}): Promise<
|
|
731
|
-
template(option: MethodOption & {
|
|
946
|
+
columns?: (keyof L)[];
|
|
947
|
+
}): Promise<L | null>;
|
|
948
|
+
template<L = T>(option: MethodOption & {
|
|
732
949
|
templateResult: TemplateResult.Many;
|
|
733
950
|
id?: string | number | Array<string | number>;
|
|
734
|
-
where?: Partial<
|
|
951
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
952
|
+
skipUndefined?: boolean;
|
|
953
|
+
skipNull?: boolean;
|
|
954
|
+
skipEmptyString?: boolean;
|
|
735
955
|
mode?: SelectMode;
|
|
736
956
|
error?: string;
|
|
737
|
-
columns?: (keyof
|
|
738
|
-
}): Promise<
|
|
739
|
-
template(option: MethodOption & {
|
|
957
|
+
columns?: (keyof L)[];
|
|
958
|
+
}): Promise<L[]>;
|
|
959
|
+
template<L = T>(option: MethodOption & {
|
|
740
960
|
sync: SyncMode.Sync;
|
|
741
961
|
templateResult: TemplateResult.Many;
|
|
742
962
|
id?: string | number | Array<string | number>;
|
|
743
|
-
where?: Partial<
|
|
963
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
964
|
+
skipUndefined?: boolean;
|
|
965
|
+
skipNull?: boolean;
|
|
966
|
+
skipEmptyString?: boolean;
|
|
744
967
|
mode?: SelectMode;
|
|
745
968
|
error?: string;
|
|
746
|
-
columns?: (keyof
|
|
747
|
-
}):
|
|
748
|
-
template(option: MethodOption & {
|
|
969
|
+
columns?: (keyof L)[];
|
|
970
|
+
}): L[];
|
|
971
|
+
template<L = T>(option: MethodOption & {
|
|
749
972
|
sync: SyncMode.Async;
|
|
750
973
|
templateResult: TemplateResult.Many;
|
|
751
974
|
id?: string | number | Array<string | number>;
|
|
752
|
-
where?: Partial<
|
|
975
|
+
where?: Partial<L> | Array<Partial<L>>;
|
|
976
|
+
skipUndefined?: boolean;
|
|
977
|
+
skipNull?: boolean;
|
|
978
|
+
skipEmptyString?: boolean;
|
|
753
979
|
mode?: SelectMode;
|
|
754
980
|
error?: string;
|
|
755
|
-
columns?: (keyof
|
|
756
|
-
}): Promise<
|
|
981
|
+
columns?: (keyof L)[];
|
|
982
|
+
}): Promise<L[]>;
|
|
757
983
|
private _select;
|
|
758
984
|
/**
|
|
759
985
|
# 自由查询
|
|
@@ -783,6 +1009,7 @@ export declare class SqlService<T extends object> {
|
|
|
783
1009
|
|
|
784
1010
|
*/
|
|
785
1011
|
select<L = T>(option: MethodOption & {
|
|
1012
|
+
hump?: boolean;
|
|
786
1013
|
sync?: SyncMode.Async;
|
|
787
1014
|
selectResult?: SelectResult.Many_Row_Many_Column | SelectResult.Many_Row_One_Column;
|
|
788
1015
|
sqlId?: string;
|
|
@@ -795,6 +1022,7 @@ export declare class SqlService<T extends object> {
|
|
|
795
1022
|
errorMsg?: string;
|
|
796
1023
|
}): Promise<L[]>;
|
|
797
1024
|
select<L = T>(option: MethodOption & {
|
|
1025
|
+
hump?: boolean;
|
|
798
1026
|
sync?: SyncMode.Async;
|
|
799
1027
|
selectResult: SelectResult.One_Row_Many_Column_Assert | SelectResult.One_Row_One_Column_Assert;
|
|
800
1028
|
sqlId?: string;
|
|
@@ -807,6 +1035,7 @@ export declare class SqlService<T extends object> {
|
|
|
807
1035
|
errorMsg?: string;
|
|
808
1036
|
}): Promise<L>;
|
|
809
1037
|
select<L = T>(option: MethodOption & {
|
|
1038
|
+
hump?: boolean;
|
|
810
1039
|
sync?: SyncMode.Async;
|
|
811
1040
|
selectResult: SelectResult.One_Row_Many_Column_NotSure | SelectResult.One_Row_One_Column_NotSure;
|
|
812
1041
|
sqlId?: string;
|
|
@@ -819,6 +1048,7 @@ export declare class SqlService<T extends object> {
|
|
|
819
1048
|
errorMsg?: string;
|
|
820
1049
|
}): Promise<L | null>;
|
|
821
1050
|
select<L = T>(option: MethodOption & {
|
|
1051
|
+
hump?: boolean;
|
|
822
1052
|
sync: SyncMode.Sync;
|
|
823
1053
|
selectResult?: SelectResult.Many_Row_Many_Column | SelectResult.Many_Row_One_Column;
|
|
824
1054
|
sqlId?: string;
|
|
@@ -831,6 +1061,7 @@ export declare class SqlService<T extends object> {
|
|
|
831
1061
|
errorMsg?: string;
|
|
832
1062
|
}): L[];
|
|
833
1063
|
select<L = T>(option: MethodOption & {
|
|
1064
|
+
hump?: boolean;
|
|
834
1065
|
sync: SyncMode.Sync;
|
|
835
1066
|
selectResult: SelectResult.One_Row_Many_Column_Assert | SelectResult.One_Row_One_Column_Assert;
|
|
836
1067
|
sqlId?: string;
|
|
@@ -843,6 +1074,7 @@ export declare class SqlService<T extends object> {
|
|
|
843
1074
|
errorMsg?: string;
|
|
844
1075
|
}): L;
|
|
845
1076
|
select<L = T>(option: MethodOption & {
|
|
1077
|
+
hump?: boolean;
|
|
846
1078
|
sync: SyncMode.Sync;
|
|
847
1079
|
selectResult: SelectResult.One_Row_Many_Column_NotSure | SelectResult.One_Row_One_Column_NotSure;
|
|
848
1080
|
sqlId?: string;
|
|
@@ -908,7 +1140,31 @@ export declare class SqlService<T extends object> {
|
|
|
908
1140
|
sync: SyncMode.Sync;
|
|
909
1141
|
fn: (conn: Connection) => L;
|
|
910
1142
|
}): L | null;
|
|
911
|
-
stream(option?: MethodOption): StreamQuery<
|
|
1143
|
+
stream<L extends object = T>(option?: MethodOption): StreamQuery<L>;
|
|
1144
|
+
page<L = T>(option: MethodOption & {
|
|
1145
|
+
sync?: SyncMode.Async;
|
|
1146
|
+
sqlId: string;
|
|
1147
|
+
context?: any;
|
|
1148
|
+
params: Record<string, any>;
|
|
1149
|
+
pageSize: number;
|
|
1150
|
+
pageNumber: number;
|
|
1151
|
+
limitSelf: boolean;
|
|
1152
|
+
countSelf: boolean;
|
|
1153
|
+
sumSelf: boolean;
|
|
1154
|
+
orderBy?: string;
|
|
1155
|
+
}): Promise<PageQuery<L>>;
|
|
1156
|
+
page<L = T>(option: MethodOption & {
|
|
1157
|
+
sync: SyncMode.Sync;
|
|
1158
|
+
sqlId: string;
|
|
1159
|
+
context?: any;
|
|
1160
|
+
params: Record<string, any>;
|
|
1161
|
+
pageSize: number;
|
|
1162
|
+
pageNumber: number;
|
|
1163
|
+
limitSelf: boolean;
|
|
1164
|
+
countSelf: boolean;
|
|
1165
|
+
sumSelf: boolean;
|
|
1166
|
+
orderBy?: string;
|
|
1167
|
+
}): PageQuery<L>;
|
|
912
1168
|
/**
|
|
913
1169
|
#创建表
|
|
914
1170
|
** `tableName` 表名称
|
|
@@ -922,18 +1178,31 @@ export declare class SqlService<T extends object> {
|
|
|
922
1178
|
** `index` 表的索引,设置方式同ID
|
|
923
1179
|
*/
|
|
924
1180
|
private _createTable;
|
|
1181
|
+
private _matchSqlid;
|
|
925
1182
|
}
|
|
926
|
-
declare class
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1183
|
+
declare class StreamQuery<T extends object> {
|
|
1184
|
+
private _prefix;
|
|
1185
|
+
private _index;
|
|
1186
|
+
private _wheres;
|
|
1187
|
+
private _andQuerys;
|
|
1188
|
+
private _orQuerys;
|
|
1189
|
+
private _paramKeys;
|
|
1190
|
+
private _param;
|
|
934
1191
|
if_proceed: boolean;
|
|
935
1192
|
if_exec: boolean;
|
|
936
|
-
|
|
1193
|
+
private _table;
|
|
1194
|
+
private _distinct;
|
|
1195
|
+
private _columns;
|
|
1196
|
+
private _updates?;
|
|
1197
|
+
private _updateColumns;
|
|
1198
|
+
private _groups;
|
|
1199
|
+
private _orders;
|
|
1200
|
+
private _startRow;
|
|
1201
|
+
private _pageSize;
|
|
1202
|
+
private _service;
|
|
1203
|
+
private [_fields];
|
|
1204
|
+
private [_columns];
|
|
1205
|
+
constructor(table: string, service: SqlService<T>, __fields: Record<string, AField>, __columns: string[]);
|
|
937
1206
|
/** 将当前stream重置 */
|
|
938
1207
|
reset(): this;
|
|
939
1208
|
/** 为下次链条执行提供条件判断:非异步方法跳过,异步方法不执行并返回默认值 */
|
|
@@ -1101,44 +1370,20 @@ declare class StreamCondition<T extends object> {
|
|
|
1101
1370
|
notIncludes(key: keyof T, value: string | number, { name }?: {
|
|
1102
1371
|
name?: string;
|
|
1103
1372
|
}): this;
|
|
1104
|
-
and(fn: (stream:
|
|
1105
|
-
or(fn: (stream:
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
params: Record<string, any>;
|
|
1109
|
-
};
|
|
1110
|
-
private _;
|
|
1111
|
-
private _null;
|
|
1112
|
-
private _key;
|
|
1113
|
-
private _between;
|
|
1114
|
-
private _in;
|
|
1115
|
-
private _shift;
|
|
1116
|
-
private _match;
|
|
1117
|
-
private _pow;
|
|
1118
|
-
private _like;
|
|
1119
|
-
private _includes;
|
|
1120
|
-
}
|
|
1121
|
-
declare class StreamBuild<T extends object> extends StreamCondition<T> {
|
|
1122
|
-
protected _table: string;
|
|
1123
|
-
protected _distinct: boolean;
|
|
1124
|
-
protected _columns: string[];
|
|
1125
|
-
protected _updates?: Partial<T>;
|
|
1126
|
-
protected _updateColumns: string[];
|
|
1127
|
-
protected _groups: (keyof T)[];
|
|
1128
|
-
protected _orders: string[];
|
|
1129
|
-
protected _startRow: number;
|
|
1130
|
-
protected _pageSize: number;
|
|
1131
|
-
constructor(table: string);
|
|
1132
|
-
/** 将当前stream重置 */
|
|
1133
|
-
reset(): this;
|
|
1134
|
-
groupBy(key: keyof T): this;
|
|
1373
|
+
and(fn: StreamQuery<T> | ((stream: StreamQuery<T>) => boolean | void)): this;
|
|
1374
|
+
or(fn: StreamQuery<T> | ((stream: StreamQuery<T>) => boolean | void)): this;
|
|
1375
|
+
groupBy(...keys: (keyof T)[]): this;
|
|
1376
|
+
groupBy2(...keys: string[]): this;
|
|
1135
1377
|
asc(...keys: (keyof T)[]): this;
|
|
1378
|
+
asc2(...keys: string[]): this;
|
|
1136
1379
|
desc(...keys: (keyof T)[]): this;
|
|
1380
|
+
desc2(...keys: string[]): this;
|
|
1137
1381
|
limit(startRow: number, pageSize: number): this;
|
|
1138
1382
|
page(pageNumber: number, pageSize: number): this;
|
|
1139
1383
|
table(_table: string): this;
|
|
1140
1384
|
distinct(on?: boolean): this;
|
|
1141
|
-
|
|
1385
|
+
countDistinct(key: keyof T, countName?: string): this;
|
|
1386
|
+
count(countName?: string): this;
|
|
1142
1387
|
sum(key: keyof T, legName?: string, distinct?: boolean): this;
|
|
1143
1388
|
avg(key: keyof T, legName?: string, distinct?: boolean): this;
|
|
1144
1389
|
max(key: keyof T, legName?: string, distinct?: boolean): this;
|
|
@@ -1150,60 +1395,73 @@ declare class StreamBuild<T extends object> extends StreamCondition<T> {
|
|
|
1150
1395
|
desc?: (keyof T)[];
|
|
1151
1396
|
groupName?: string;
|
|
1152
1397
|
}): this;
|
|
1153
|
-
|
|
1154
|
-
|
|
1398
|
+
select(...key: (keyof T)[]): this;
|
|
1399
|
+
select2(sql: string, param?: Record<string, any>): this;
|
|
1400
|
+
update(key: keyof T, value: T[keyof T]): this;
|
|
1401
|
+
update2(sql: string, param?: Record<string, any>): this;
|
|
1155
1402
|
updateT(t: Partial<T>): this;
|
|
1156
1403
|
replace(key: keyof T, valueToFind: T[keyof T], valueToReplace: T[keyof T]): this;
|
|
1157
|
-
|
|
1158
|
-
declare class StreamQuery<T extends object> extends StreamBuild<T> {
|
|
1159
|
-
private _service;
|
|
1160
|
-
constructor(table: string, service: SqlService<T>);
|
|
1161
|
-
select<L = T>(option: {
|
|
1404
|
+
excuteSelect<L = T>(option?: MethodOption & {
|
|
1162
1405
|
sync?: SyncMode.Async;
|
|
1163
|
-
selectResult
|
|
1406
|
+
selectResult?: SelectResult.Many_Row_Many_Column | SelectResult.Many_Row_One_Column;
|
|
1164
1407
|
}): Promise<L[]>;
|
|
1165
|
-
|
|
1408
|
+
excuteSelect<L = T>(option: MethodOption & {
|
|
1166
1409
|
sync?: SyncMode.Async;
|
|
1167
1410
|
selectResult: SelectResult.One_Row_Many_Column_Assert | SelectResult.One_Row_One_Column_Assert;
|
|
1168
1411
|
errorMsg?: string;
|
|
1169
1412
|
}): Promise<L>;
|
|
1170
|
-
|
|
1413
|
+
excuteSelect<L = T>(option: MethodOption & {
|
|
1171
1414
|
sync?: SyncMode.Async;
|
|
1172
1415
|
selectResult: SelectResult.One_Row_Many_Column_NotSure | SelectResult.One_Row_One_Column_NotSure;
|
|
1173
1416
|
}): Promise<L | null>;
|
|
1174
|
-
|
|
1417
|
+
excuteSelect<L = T>(option: MethodOption & {
|
|
1175
1418
|
sync: SyncMode.Sync;
|
|
1176
1419
|
selectResult: SelectResult.Many_Row_Many_Column | SelectResult.Many_Row_One_Column;
|
|
1177
1420
|
}): L[];
|
|
1178
|
-
|
|
1421
|
+
excuteSelect<L = T>(option: MethodOption & {
|
|
1179
1422
|
sync: SyncMode.Sync;
|
|
1180
1423
|
selectResult: SelectResult.One_Row_Many_Column_Assert | SelectResult.One_Row_One_Column_Assert;
|
|
1181
1424
|
errorMsg?: string;
|
|
1182
1425
|
}): L;
|
|
1183
|
-
|
|
1426
|
+
excuteSelect<L = T>(option: MethodOption & {
|
|
1184
1427
|
sync: SyncMode.Sync;
|
|
1185
1428
|
selectResult: SelectResult.One_Row_Many_Column_NotSure | SelectResult.One_Row_One_Column_NotSure;
|
|
1186
1429
|
}): L | null;
|
|
1187
|
-
|
|
1430
|
+
excuteUpdate(option?: MethodOption & {
|
|
1188
1431
|
sync?: SyncMode.Async;
|
|
1189
1432
|
}): Promise<number>;
|
|
1190
|
-
|
|
1433
|
+
excuteUpdate(option: MethodOption & {
|
|
1191
1434
|
sync: SyncMode.Sync;
|
|
1192
1435
|
}): number;
|
|
1193
|
-
|
|
1436
|
+
excuteDelete(option?: MethodOption & {
|
|
1194
1437
|
sync?: SyncMode.Async;
|
|
1195
1438
|
}): Promise<number>;
|
|
1196
|
-
|
|
1439
|
+
excuteDelete(option: MethodOption & {
|
|
1197
1440
|
sync: SyncMode.Sync;
|
|
1198
1441
|
}): number;
|
|
1442
|
+
private _where;
|
|
1443
|
+
private _;
|
|
1444
|
+
private _null;
|
|
1445
|
+
private _key;
|
|
1446
|
+
private _between;
|
|
1447
|
+
private _in;
|
|
1448
|
+
private _shift;
|
|
1449
|
+
private _match;
|
|
1450
|
+
private _pow;
|
|
1451
|
+
private _like;
|
|
1452
|
+
private _includes;
|
|
1199
1453
|
}
|
|
1200
1454
|
/**
|
|
1201
1455
|
获取REDIS客户端,
|
|
1202
1456
|
# [查看库的API](https://github.com/redis/ioredis?tab=readme-ov-file)
|
|
1203
1457
|
# [REDIS API](http://doc.redisfans.com/)
|
|
1204
1458
|
REDIS 的API 可以直接用,将方法名转为小写
|
|
1459
|
+
```
|
|
1460
|
+
// 设置<Redis>来获得代码提示
|
|
1461
|
+
getRedisDB<Redis>('').exists(?)
|
|
1462
|
+
```
|
|
1205
1463
|
*/
|
|
1206
|
-
export declare function getRedisDB(db?: string):
|
|
1464
|
+
export declare function getRedisDB<T = any>(db?: string): T;
|
|
1207
1465
|
/**
|
|
1208
1466
|
redlock
|
|
1209
1467
|
*/
|
|
@@ -1262,5 +1520,4 @@ export declare function MethodCache<T = any>(config: {
|
|
|
1262
1520
|
/** 随着当前用户sesion的清空而一起清空 */
|
|
1263
1521
|
clearWithSession?: boolean;
|
|
1264
1522
|
}): (target: T, _propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
1265
|
-
export declare const Boot: (options: GlobalSqlOption) => Promise<void>;
|
|
1266
1523
|
export {};
|