imodel 0.19.2 → 0.20.0
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/index.d.mts +383 -106
- package/index.mjs +3051 -2399
- package/migrate.d.mts +5 -4
- package/migrate.mjs +22 -3
- package/package.json +3 -1
package/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.
|
|
3
|
-
* (c) 2019-2026
|
|
4
|
-
* @license
|
|
2
|
+
* imodel v0.20.0
|
|
3
|
+
* (c) 2019-2026 猛火Fierflame
|
|
4
|
+
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
declare const now: unique symbol;
|
|
@@ -17,7 +17,15 @@ declare const coefficient$1: unique symbol;
|
|
|
17
17
|
declare const values_now: typeof now;
|
|
18
18
|
declare const values_uuid: typeof uuid;
|
|
19
19
|
declare namespace values {
|
|
20
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
coefficient$1 as coefficient,
|
|
22
|
+
decrement$1 as decrement,
|
|
23
|
+
divide$1 as divide,
|
|
24
|
+
increment$1 as increment,
|
|
25
|
+
multiply$1 as multiply,
|
|
26
|
+
values_now as now,
|
|
27
|
+
values_uuid as uuid,
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
/**
|
|
@@ -339,14 +347,14 @@ declare function pseudo(pseudo: string): ClassDecorator;
|
|
|
339
347
|
* @param {now} value
|
|
340
348
|
* @returns {FieldDecorator<string | Date>}
|
|
341
349
|
*/
|
|
342
|
-
declare function defaultValue<T>(value:
|
|
350
|
+
declare function defaultValue<T>(value: typeof now): FieldDecorator<string | Date>;
|
|
343
351
|
/**
|
|
344
352
|
* @template T
|
|
345
353
|
* @overload
|
|
346
354
|
* @param {uuid} value
|
|
347
355
|
* @returns {FieldDecorator<string>}
|
|
348
356
|
*/
|
|
349
|
-
declare function defaultValue<T>(value:
|
|
357
|
+
declare function defaultValue<T>(value: typeof uuid): FieldDecorator<string>;
|
|
350
358
|
/**
|
|
351
359
|
* @template T
|
|
352
360
|
* @overload
|
|
@@ -508,10 +516,136 @@ type FieldDecorator<T> = (val: {
|
|
|
508
516
|
}, ctx: ClassAccessorDecoratorContext) => any;
|
|
509
517
|
type MethodDecorator<T extends Function> = (val: T, ctx: ClassMethodDecoratorContext<any, T>) => any;
|
|
510
518
|
|
|
511
|
-
|
|
512
|
-
|
|
519
|
+
declare class ConnectionError extends Error {
|
|
520
|
+
/**
|
|
521
|
+
* @param {string} code - 自定义通用错误码 (例如 constraint:unique)
|
|
522
|
+
* @param {string} message - 原始错误信息或自定义信息
|
|
523
|
+
*/
|
|
524
|
+
constructor(code: string, message: string);
|
|
525
|
+
/** @type {string} */
|
|
526
|
+
code: string;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* 非空约束违规
|
|
530
|
+
* 对应 PG 23502 / MySQL 1048
|
|
531
|
+
* 场景:插入数据时,必填字段为空
|
|
532
|
+
*/
|
|
533
|
+
declare class NotNullViolationError extends ConnectionError {
|
|
534
|
+
/** @type {string} */
|
|
535
|
+
table: string;
|
|
536
|
+
/** @type {string} */
|
|
537
|
+
column: string;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* 唯一性约束违规
|
|
541
|
+
* 对应 PG 23505 / MySQL 1062
|
|
542
|
+
* 支持单字段和多字段组合冲突
|
|
543
|
+
*/
|
|
544
|
+
declare class UniqueViolationError extends ConnectionError {
|
|
545
|
+
/**
|
|
546
|
+
* @param {string} table - 表名
|
|
547
|
+
* @param {string | string[]} columns - 冲突的列名(可以是字符串或字符串数组)
|
|
548
|
+
* @param {any} [values] - 导致冲突的值(可选,多字段时为对象或数组)
|
|
549
|
+
*/
|
|
550
|
+
constructor(table: string, columns: string | string[], values?: any);
|
|
551
|
+
/** @type {string} */
|
|
552
|
+
table: string;
|
|
553
|
+
/** @type {string[]} */
|
|
554
|
+
columns: string[];
|
|
555
|
+
/** @type {any} */
|
|
556
|
+
values: any;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* 外键约束违规
|
|
560
|
+
* 对应 PG 23503 / MySQL 1452
|
|
561
|
+
* 场景:插入了一个不存在的 user_id
|
|
562
|
+
*/
|
|
563
|
+
declare class ForeignKeyViolationError extends ConnectionError {
|
|
564
|
+
/**
|
|
565
|
+
* @param {string} table - 当前操作的表
|
|
566
|
+
* @param {string | string[]} columns - 当前操作的外键列
|
|
567
|
+
* @param {string} [referencedTable] - 被引用的父表
|
|
568
|
+
*/
|
|
569
|
+
constructor(table: string, columns: string | string[], referencedTable?: string);
|
|
570
|
+
/** @type {string} */
|
|
571
|
+
table: string;
|
|
572
|
+
/** @type {string[]} */
|
|
573
|
+
columns: string[];
|
|
574
|
+
/** @type {string} */
|
|
575
|
+
referencedTable: string;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* 检查约束违规
|
|
579
|
+
* 对应 PG 23514
|
|
580
|
+
* 场景:年龄字段要求 > 0,但插入了 -5
|
|
581
|
+
*/
|
|
582
|
+
declare class CheckViolationError extends ConnectionError {
|
|
583
|
+
/**
|
|
584
|
+
* @param {string} table - 当前操作的表
|
|
585
|
+
* @param {string} [constraint] - 当前操作的外键列
|
|
586
|
+
*/
|
|
587
|
+
constructor(table: string, constraint?: string);
|
|
588
|
+
/** @type {string} */
|
|
589
|
+
table: string;
|
|
590
|
+
/** @type {string} */
|
|
591
|
+
constraint: string;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* 无效的类型输入语法错误
|
|
595
|
+
* 对应 PG 22P02
|
|
596
|
+
* 场景:无效的 UUID、日期格式错误等
|
|
597
|
+
*/
|
|
598
|
+
declare class InvalidInputSyntaxError extends ConnectionError {
|
|
599
|
+
/**
|
|
600
|
+
* @param {string} message - 目标数据类型
|
|
601
|
+
*/
|
|
602
|
+
constructor(message: string);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* 操作符不匹配错误
|
|
606
|
+
* 对应 PG 42883
|
|
607
|
+
* 场景:uuid = integer 等类型不兼容的操作
|
|
608
|
+
*/
|
|
609
|
+
declare class OperatorMismatchError extends ConnectionError {
|
|
610
|
+
/**
|
|
611
|
+
* @param {string} message
|
|
612
|
+
*/
|
|
613
|
+
constructor(message: string);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
type errors_CheckViolationError = CheckViolationError;
|
|
617
|
+
declare const errors_CheckViolationError: typeof CheckViolationError;
|
|
618
|
+
type errors_ConnectionError = ConnectionError;
|
|
619
|
+
declare const errors_ConnectionError: typeof ConnectionError;
|
|
620
|
+
type errors_ForeignKeyViolationError = ForeignKeyViolationError;
|
|
621
|
+
declare const errors_ForeignKeyViolationError: typeof ForeignKeyViolationError;
|
|
622
|
+
type errors_InvalidInputSyntaxError = InvalidInputSyntaxError;
|
|
623
|
+
declare const errors_InvalidInputSyntaxError: typeof InvalidInputSyntaxError;
|
|
624
|
+
type errors_NotNullViolationError = NotNullViolationError;
|
|
625
|
+
declare const errors_NotNullViolationError: typeof NotNullViolationError;
|
|
626
|
+
type errors_OperatorMismatchError = OperatorMismatchError;
|
|
627
|
+
declare const errors_OperatorMismatchError: typeof OperatorMismatchError;
|
|
628
|
+
type errors_UniqueViolationError = UniqueViolationError;
|
|
629
|
+
declare const errors_UniqueViolationError: typeof UniqueViolationError;
|
|
630
|
+
declare namespace errors {
|
|
631
|
+
export {
|
|
632
|
+
errors_CheckViolationError as CheckViolationError,
|
|
633
|
+
errors_ConnectionError as ConnectionError,
|
|
634
|
+
errors_ForeignKeyViolationError as ForeignKeyViolationError,
|
|
635
|
+
errors_InvalidInputSyntaxError as InvalidInputSyntaxError,
|
|
636
|
+
errors_NotNullViolationError as NotNullViolationError,
|
|
637
|
+
errors_OperatorMismatchError as OperatorMismatchError,
|
|
638
|
+
errors_UniqueViolationError as UniqueViolationError,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
interface BaseEnvironment {
|
|
513
643
|
isDevelopment: boolean;
|
|
514
644
|
values: typeof values;
|
|
645
|
+
errors: typeof errors;
|
|
646
|
+
}
|
|
647
|
+
interface Environment<T extends object> extends BaseEnvironment {
|
|
648
|
+
readonly transaction: T | null;
|
|
515
649
|
}
|
|
516
650
|
|
|
517
651
|
/** 特性支持情况 */
|
|
@@ -543,69 +677,6 @@ interface Column<T> extends ColumnOptions<T> {
|
|
|
543
677
|
type: string;
|
|
544
678
|
}
|
|
545
679
|
|
|
546
|
-
/** @typedef {SetValue.Increment | SetValue.Decrement | SetValue.Multiply | SetValue.Divide | SetValue.Coefficient | string | number | bigint | boolean | null | typeof now | typeof uuid | (string | number | bigint | boolean)[]} SetValue */
|
|
547
|
-
/** @typedef {{[values.increment]: number | bigint}} SetValue.Increment */
|
|
548
|
-
/** @typedef {{[values.decrement]: number | bigint}} SetValue.Decrement */
|
|
549
|
-
/** @typedef {{[values.multiply]: number | bigint}} SetValue.Multiply */
|
|
550
|
-
/** @typedef {{[values.divide]: number | bigint}} SetValue.Divide */
|
|
551
|
-
/** @typedef {{[values.coefficient]: (number | bigint)[]}} SetValue.Coefficient */
|
|
552
|
-
/**
|
|
553
|
-
* @param {number | bigint} value
|
|
554
|
-
* @returns {SetValue.Increment}
|
|
555
|
-
*/
|
|
556
|
-
declare function increment(value: number | bigint): SetValue.Increment;
|
|
557
|
-
/**
|
|
558
|
-
* @param {number | bigint} value
|
|
559
|
-
* @returns {SetValue.Decrement}
|
|
560
|
-
*/
|
|
561
|
-
declare function decrement(value: number | bigint): SetValue.Decrement;
|
|
562
|
-
/**
|
|
563
|
-
* @param {number | bigint} value
|
|
564
|
-
* @returns {SetValue.Multiply}
|
|
565
|
-
*/
|
|
566
|
-
declare function multiply(value: number | bigint): SetValue.Multiply;
|
|
567
|
-
/**
|
|
568
|
-
* @param {number | bigint} value
|
|
569
|
-
* @returns {SetValue.Divide}
|
|
570
|
-
*/
|
|
571
|
-
declare function divide(value: number | bigint): SetValue.Divide;
|
|
572
|
-
/**
|
|
573
|
-
* @param {...number | bigint} value
|
|
574
|
-
* @returns {SetValue.Coefficient}
|
|
575
|
-
*/
|
|
576
|
-
declare function coefficient(...value: (number | bigint)[]): SetValue.Coefficient;
|
|
577
|
-
type SetValue = SetValue.Increment | SetValue.Decrement | SetValue.Multiply | SetValue.Divide | SetValue.Coefficient | string | number | bigint | boolean | null | typeof now | typeof uuid | (string | number | bigint | boolean)[];
|
|
578
|
-
declare namespace SetValue {
|
|
579
|
-
type Increment = {
|
|
580
|
-
[increment$1]: number | bigint;
|
|
581
|
-
};
|
|
582
|
-
type Decrement = {
|
|
583
|
-
[decrement$1]: number | bigint;
|
|
584
|
-
};
|
|
585
|
-
type Multiply = {
|
|
586
|
-
[multiply$1]: number | bigint;
|
|
587
|
-
};
|
|
588
|
-
type Divide = {
|
|
589
|
-
[divide$1]: number | bigint;
|
|
590
|
-
};
|
|
591
|
-
type Coefficient = {
|
|
592
|
-
[coefficient$1]: (number | bigint)[];
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
interface VirtualTable<E extends object = object> {
|
|
597
|
-
insert(environment: Environment<E>, conn: TableConnection<E>, columns: Record<string, DBColumn>, data: object[], key: string[], ignoreConflict?: boolean): PromiseLike<any[]>;
|
|
598
|
-
upsert(environment: Environment<E>, conn: TableConnection<E>, columns: Record<string, DBColumn>, data: object[], key: string[], conflict: true | string[], conflictSet?: Record<string, SetValue>): PromiseLike<any[]>;
|
|
599
|
-
update(environment: Environment<E>, conn: TableConnection<E>, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
600
|
-
updateReturn(environment: Environment<E>, conn: TableConnection<E>, returning: string[], columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
601
|
-
updateMany(environment: Environment<E>, conn: TableConnection<E>, fields: Fields<keyof FieldType>, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<number>;
|
|
602
|
-
updateManyReturn(environment: Environment<E>, conn: TableConnection<E>, fields: Fields<keyof FieldType>, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[], returning: string[]): PromiseLike<any[]>;
|
|
603
|
-
count(environment: Environment<E>, conn: TableConnection<E>, columns: Record<string, DBColumn>, where: WhereValue[]): PromiseLike<number>;
|
|
604
|
-
select(environment: Environment<E>, conn: TableConnection<E>, select: SelectItem[]): PromiseLike<any[]>;
|
|
605
|
-
delete(environment: Environment<E>, conn: TableConnection<E>, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
606
|
-
deleteReturn(environment: Environment<E>, conn: TableConnection<E>, returning: string[], columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
680
|
type MaybePromise<T> = PromiseLike<T> | T;
|
|
610
681
|
|
|
611
682
|
interface Hook<T extends Hooks[keyof Hooks]> {
|
|
@@ -1318,8 +1389,8 @@ interface Hooks<T extends Record<string, any> = Record<string, any>> {
|
|
|
1318
1389
|
beforeDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
1319
1390
|
afterDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
1320
1391
|
}
|
|
1321
|
-
interface TableDefine<T extends Fields = Fields, TT extends string |
|
|
1322
|
-
readonly connect?: TableConnect
|
|
1392
|
+
interface TableDefine<T extends Fields = Fields, TT extends string | undefined = string | undefined> {
|
|
1393
|
+
readonly connect?: TableConnect | null;
|
|
1323
1394
|
/** 字段信息 */
|
|
1324
1395
|
readonly fields: T;
|
|
1325
1396
|
/** 表名 */
|
|
@@ -1341,6 +1412,56 @@ type withDeleted = typeof withDeleted;
|
|
|
1341
1412
|
declare const withDeleted: unique symbol;
|
|
1342
1413
|
type FindRange = deleted | undeleted | withDeleted;
|
|
1343
1414
|
|
|
1415
|
+
/** @typedef {SetValue.Increment | SetValue.Decrement | SetValue.Multiply | SetValue.Divide | SetValue.Coefficient | string | number | bigint | boolean | null | typeof now | typeof uuid | (string | number | bigint | boolean)[]} SetValue */
|
|
1416
|
+
/** @typedef {{[values.increment]: number | bigint}} SetValue.Increment */
|
|
1417
|
+
/** @typedef {{[values.decrement]: number | bigint}} SetValue.Decrement */
|
|
1418
|
+
/** @typedef {{[values.multiply]: number | bigint}} SetValue.Multiply */
|
|
1419
|
+
/** @typedef {{[values.divide]: number | bigint}} SetValue.Divide */
|
|
1420
|
+
/** @typedef {{[values.coefficient]: (number | bigint)[]}} SetValue.Coefficient */
|
|
1421
|
+
/**
|
|
1422
|
+
* @param {number | bigint} value
|
|
1423
|
+
* @returns {SetValue.Increment}
|
|
1424
|
+
*/
|
|
1425
|
+
declare function increment(value: number | bigint): SetValue.Increment;
|
|
1426
|
+
/**
|
|
1427
|
+
* @param {number | bigint} value
|
|
1428
|
+
* @returns {SetValue.Decrement}
|
|
1429
|
+
*/
|
|
1430
|
+
declare function decrement(value: number | bigint): SetValue.Decrement;
|
|
1431
|
+
/**
|
|
1432
|
+
* @param {number | bigint} value
|
|
1433
|
+
* @returns {SetValue.Multiply}
|
|
1434
|
+
*/
|
|
1435
|
+
declare function multiply(value: number | bigint): SetValue.Multiply;
|
|
1436
|
+
/**
|
|
1437
|
+
* @param {number | bigint} value
|
|
1438
|
+
* @returns {SetValue.Divide}
|
|
1439
|
+
*/
|
|
1440
|
+
declare function divide(value: number | bigint): SetValue.Divide;
|
|
1441
|
+
/**
|
|
1442
|
+
* @param {...number | bigint} value
|
|
1443
|
+
* @returns {SetValue.Coefficient}
|
|
1444
|
+
*/
|
|
1445
|
+
declare function coefficient(...value: (number | bigint)[]): SetValue.Coefficient;
|
|
1446
|
+
type SetValue = SetValue.Increment | SetValue.Decrement | SetValue.Multiply | SetValue.Divide | SetValue.Coefficient | string | number | bigint | boolean | null | typeof now | typeof uuid | (string | number | bigint | boolean)[];
|
|
1447
|
+
declare namespace SetValue {
|
|
1448
|
+
type Increment = {
|
|
1449
|
+
[increment$1]: number | bigint;
|
|
1450
|
+
};
|
|
1451
|
+
type Decrement = {
|
|
1452
|
+
[decrement$1]: number | bigint;
|
|
1453
|
+
};
|
|
1454
|
+
type Multiply = {
|
|
1455
|
+
[multiply$1]: number | bigint;
|
|
1456
|
+
};
|
|
1457
|
+
type Divide = {
|
|
1458
|
+
[divide$1]: number | bigint;
|
|
1459
|
+
};
|
|
1460
|
+
type Coefficient = {
|
|
1461
|
+
[coefficient$1]: (number | bigint)[];
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1344
1465
|
type Select = {
|
|
1345
1466
|
field: string;
|
|
1346
1467
|
table?: string;
|
|
@@ -1399,11 +1520,13 @@ interface JOIN {
|
|
|
1399
1520
|
condition?: WhereValue[];
|
|
1400
1521
|
}
|
|
1401
1522
|
type LockType = 'S' | 'X';
|
|
1402
|
-
interface
|
|
1403
|
-
distinct?: boolean;
|
|
1404
|
-
select: [string, Select][];
|
|
1523
|
+
interface IDBTable {
|
|
1405
1524
|
table: string;
|
|
1406
1525
|
columns: Record<string, DBColumn>;
|
|
1526
|
+
}
|
|
1527
|
+
interface SelectItem extends IDBTable {
|
|
1528
|
+
distinct?: boolean;
|
|
1529
|
+
select: [string, Select][];
|
|
1407
1530
|
alias?: string;
|
|
1408
1531
|
/** 匹配信息 */
|
|
1409
1532
|
where: WhereValue[];
|
|
@@ -1439,9 +1562,35 @@ interface DBTable {
|
|
|
1439
1562
|
indexes?: DBIndex[];
|
|
1440
1563
|
primary?: string;
|
|
1441
1564
|
}
|
|
1565
|
+
interface Savepoint {
|
|
1566
|
+
readonly name: string;
|
|
1567
|
+
rollback(): Promise<void>;
|
|
1568
|
+
release(): Promise<void>;
|
|
1569
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1570
|
+
}
|
|
1571
|
+
interface ConnectionInterface {
|
|
1572
|
+
insert(table: IDBTable, data: object[], key: string[], conflictTarget?: string[] | boolean, conflictSet?: Record<string, SetValue> | boolean, conflictWhere?: WhereValue[]): PromiseLike<any[]>;
|
|
1573
|
+
update(table: IDBTable, update: Record<string, SetValue>, where?: WhereValue[]): PromiseLike<number>;
|
|
1574
|
+
updateReturn(returning: string[], table: IDBTable, update: Record<string, SetValue>, where?: WhereValue[]): PromiseLike<any[]>;
|
|
1575
|
+
updateList(table: IDBTable, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<number>;
|
|
1576
|
+
updateListReturn(returning: string[], table: IDBTable, update: Record<string, any>, primaryKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<any[]>;
|
|
1577
|
+
count(table: IDBTable, where?: WhereValue[]): PromiseLike<number>;
|
|
1578
|
+
select(select: SelectItem): PromiseLike<any[]>;
|
|
1579
|
+
delete(table: IDBTable, where?: WhereValue[]): PromiseLike<number>;
|
|
1580
|
+
deleteReturn(returning: string[], table: IDBTable, where?: WhereValue[]): PromiseLike<any[]>;
|
|
1581
|
+
transaction<T>(fn: (signal: AbortSignal) => PromiseLike<T> | T): PromiseLike<T>;
|
|
1582
|
+
abort(): boolean;
|
|
1583
|
+
savepoint(): PromiseLike<Savepoint>;
|
|
1584
|
+
}
|
|
1585
|
+
interface TableConnect {
|
|
1586
|
+
(conn: ConnectionInterface, env: BaseEnvironment): ConnectionInterface;
|
|
1587
|
+
}
|
|
1588
|
+
interface Action<T> {
|
|
1589
|
+
invoke(connect: () => Promise<ConnectionInterface>, connection: Connection, environment: BaseEnvironment): PromiseLike<T> | T;
|
|
1590
|
+
connect?: TableConnect | null;
|
|
1591
|
+
}
|
|
1442
1592
|
interface TableConnection<E extends object = object> {
|
|
1443
|
-
insert(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, data: object[], key: string[],
|
|
1444
|
-
upsert(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, data: object[], key: string[], conflict: true | string[], conflictSet?: Record<string, SetValue>): PromiseLike<any[]>;
|
|
1593
|
+
insert(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, data: object[], key: string[], conflictTarget?: string[] | boolean, conflictSet?: Record<string, SetValue> | boolean, conflictWhere?: WhereValue[] | null): PromiseLike<any[]>;
|
|
1445
1594
|
update(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
1446
1595
|
updateReturn(environment: Environment<E>, returning: string[], table: string, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
1447
1596
|
updateMany(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<number>;
|
|
@@ -1463,6 +1612,9 @@ interface IConnection<E extends object = object> extends TableConnection<E> {
|
|
|
1463
1612
|
*/
|
|
1464
1613
|
query(environment: Environment<E>, ...values: any): PromiseLike<any[]>;
|
|
1465
1614
|
type(environment: Environment<E>, table: string): PromiseLike<TableType | null>;
|
|
1615
|
+
createSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
1616
|
+
rollbackSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
1617
|
+
releaseSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
1466
1618
|
createTable(environment: Environment<E>, table: string, columns: Column<any>[]): PromiseLike<number>;
|
|
1467
1619
|
dropTable(environment: Environment<E>, table: string): PromiseLike<number>;
|
|
1468
1620
|
renameTable(environment: Environment<E>, table: string, newName: string): PromiseLike<number>;
|
|
@@ -1477,9 +1629,6 @@ interface IConnection<E extends object = object> extends TableConnection<E> {
|
|
|
1477
1629
|
syncTables(environment: Environment<E>, tables: DBTable[]): PromiseLike<void>;
|
|
1478
1630
|
transaction<R>(environment: Environment<E>, fn: (t: E) => R | PromiseLike<R>): PromiseLike<R>;
|
|
1479
1631
|
}
|
|
1480
|
-
interface TableConnect<E extends object = object> {
|
|
1481
|
-
(conn: IConnection<E>): TableConnection<E>;
|
|
1482
|
-
}
|
|
1483
1632
|
interface Skip {
|
|
1484
1633
|
uncreatable?: boolean;
|
|
1485
1634
|
immutable?: boolean;
|
|
@@ -1537,6 +1686,12 @@ declare class Connection<E extends {} = {}> {
|
|
|
1537
1686
|
* @returns {Connection<E>}
|
|
1538
1687
|
*/
|
|
1539
1688
|
clone(): Connection<E>;
|
|
1689
|
+
/**
|
|
1690
|
+
* @template T
|
|
1691
|
+
* @param {Action<T>} action
|
|
1692
|
+
* @returns {Promise<T>}
|
|
1693
|
+
*/
|
|
1694
|
+
call<T>(action: Action<T>): Promise<T>;
|
|
1540
1695
|
/** @return {Promise<string>} */
|
|
1541
1696
|
dbType(): Promise<string>;
|
|
1542
1697
|
/** @return {Promise<string>} */
|
|
@@ -1578,6 +1733,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1578
1733
|
*/
|
|
1579
1734
|
build<T extends Fields>(table: TableDefine<T>, data: object, saved?: object | boolean): FieldValue<T>;
|
|
1580
1735
|
/**
|
|
1736
|
+
* @deprecated
|
|
1581
1737
|
* @template {TableDefine} T
|
|
1582
1738
|
* @overload
|
|
1583
1739
|
* @param {T} model
|
|
@@ -1586,6 +1742,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1586
1742
|
*/
|
|
1587
1743
|
create<T extends TableDefine>(model: T, list: object[]): Promise<TableValue<T>[]>;
|
|
1588
1744
|
/**
|
|
1745
|
+
* @deprecated
|
|
1589
1746
|
* @template {TableDefine} T
|
|
1590
1747
|
* @overload
|
|
1591
1748
|
* @param {T} model
|
|
@@ -1594,6 +1751,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1594
1751
|
*/
|
|
1595
1752
|
create<T extends TableDefine>(model: T, value: object): Promise<T extends Build<infer R> ? R : TableValue<T>>;
|
|
1596
1753
|
/**
|
|
1754
|
+
* @deprecated
|
|
1597
1755
|
* @template {TableDefine} T
|
|
1598
1756
|
* @overload
|
|
1599
1757
|
* @param {T} model
|
|
@@ -1603,6 +1761,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1603
1761
|
create<T extends TableDefine>(model: T, value: object | object[]): Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>;
|
|
1604
1762
|
/**
|
|
1605
1763
|
*
|
|
1764
|
+
* @deprecated
|
|
1606
1765
|
* @template {TableDefine} T
|
|
1607
1766
|
* @param {T} sql
|
|
1608
1767
|
* @param {string[]} fields
|
|
@@ -1611,7 +1770,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1611
1770
|
*/
|
|
1612
1771
|
search<T extends TableDefine>(sql: T, fields: string[], skip?: Skip): Promise<T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
1613
1772
|
/**
|
|
1614
|
-
*
|
|
1773
|
+
* @deprecated
|
|
1615
1774
|
* @template {TableDefine} T
|
|
1616
1775
|
* @param {T} sql
|
|
1617
1776
|
* @param {Skip} [skip]
|
|
@@ -1620,6 +1779,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1620
1779
|
find<T extends TableDefine>(sql: T, skip?: Skip): Promise<T extends Build<infer R> ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
1621
1780
|
/**
|
|
1622
1781
|
*
|
|
1782
|
+
* @deprecated
|
|
1623
1783
|
* @template {TableDefine} T
|
|
1624
1784
|
* @param {T} sql
|
|
1625
1785
|
* @param {Skip} [skip]
|
|
@@ -1627,6 +1787,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1627
1787
|
*/
|
|
1628
1788
|
first<T extends TableDefine>(sql: T, skip?: Skip): Promise<T extends Build<infer R> ? R : T extends TableDefine<infer F> ? FieldValue<F> : never>;
|
|
1629
1789
|
/**
|
|
1790
|
+
* @deprecated
|
|
1630
1791
|
* @template T
|
|
1631
1792
|
* @param {TableDefine} model
|
|
1632
1793
|
* @param {T} data
|
|
@@ -1637,6 +1798,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1637
1798
|
save<T>(model: TableDefine, data: T, newData?: Record<string, any> | null, skip?: Skip): Promise<(T extends Save ? T : object) | null>;
|
|
1638
1799
|
/**
|
|
1639
1800
|
*
|
|
1801
|
+
* @deprecated
|
|
1640
1802
|
* @template T
|
|
1641
1803
|
* @param {TableDefine} tableDef
|
|
1642
1804
|
* @param {T} data
|
|
@@ -1645,6 +1807,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1645
1807
|
completelyDestroy<T>(tableDef: TableDefine, data: T): Promise<(T extends Destroy ? T : object) | null>;
|
|
1646
1808
|
/**
|
|
1647
1809
|
*
|
|
1810
|
+
* @deprecated
|
|
1648
1811
|
* @template {object} T
|
|
1649
1812
|
* @param {TableDefine} tableDef
|
|
1650
1813
|
* @param {T} data
|
|
@@ -1653,6 +1816,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1653
1816
|
*/
|
|
1654
1817
|
pseudoDestroy<T extends unknown>(tableDef: TableDefine, data: T, value: Record<string, SetValue>): Promise<(T extends PseudoDestroy ? T : object) | null>;
|
|
1655
1818
|
/**
|
|
1819
|
+
* @deprecated
|
|
1656
1820
|
* @template {Destroy & PseudoDestroy} T
|
|
1657
1821
|
* @overload
|
|
1658
1822
|
* @param {TableDefine} table
|
|
@@ -1662,6 +1826,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1662
1826
|
*/
|
|
1663
1827
|
destroy<T extends Destroy & PseudoDestroy>(table: TableDefine, data: T, update?: boolean | Record<string, any> | undefined): Promise<T | null>;
|
|
1664
1828
|
/**
|
|
1829
|
+
* @deprecated
|
|
1665
1830
|
* @template {Destroy & PseudoDestroy} T
|
|
1666
1831
|
* @overload
|
|
1667
1832
|
* @param {TableDefine} table
|
|
@@ -1671,6 +1836,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1671
1836
|
*/
|
|
1672
1837
|
destroy<T extends Destroy & PseudoDestroy>(table: TableDefine, data: T, update?: boolean | Record<string, any> | undefined): Promise<T | object | null>;
|
|
1673
1838
|
/**
|
|
1839
|
+
* @deprecated
|
|
1674
1840
|
* @overload
|
|
1675
1841
|
* @param {TableDefine} table
|
|
1676
1842
|
* @param {any} data
|
|
@@ -1679,12 +1845,14 @@ declare class Connection<E extends {} = {}> {
|
|
|
1679
1845
|
*/
|
|
1680
1846
|
destroy(table: TableDefine, data: any, update?: boolean | Record<string, any> | undefined): Promise<object | null>;
|
|
1681
1847
|
/**
|
|
1848
|
+
* @deprecated
|
|
1682
1849
|
* @param {Queryable} queryable
|
|
1683
1850
|
* @param {Record<string, SetValue> | boolean} [update]
|
|
1684
1851
|
* @returns {Promise<number>}
|
|
1685
1852
|
*/
|
|
1686
1853
|
destroyMany(queryable: Queryable, update?: Record<string, SetValue> | boolean): Promise<number>;
|
|
1687
1854
|
/**
|
|
1855
|
+
* @deprecated
|
|
1688
1856
|
* @template {object} T
|
|
1689
1857
|
* @overload
|
|
1690
1858
|
* @param {TableDefine} tableDefine
|
|
@@ -1694,6 +1862,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1694
1862
|
*/
|
|
1695
1863
|
insert<T extends unknown>(tableDefine: TableDefine, data: T, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1696
1864
|
/**
|
|
1865
|
+
* @deprecated
|
|
1697
1866
|
* @template {object} T
|
|
1698
1867
|
* @overload
|
|
1699
1868
|
* @param {TableDefine} tableDefine
|
|
@@ -1703,6 +1872,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1703
1872
|
*/
|
|
1704
1873
|
insert<T extends unknown>(tableDefine: TableDefine, data: T[], ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1705
1874
|
/**
|
|
1875
|
+
* @deprecated
|
|
1706
1876
|
* @template {object} T
|
|
1707
1877
|
* @overload
|
|
1708
1878
|
* @param {TableDefine} tableDefine
|
|
@@ -1713,6 +1883,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1713
1883
|
*/
|
|
1714
1884
|
insert<T extends unknown>(tableDefine: TableDefine, data: T, keys?: string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1715
1885
|
/**
|
|
1886
|
+
* @deprecated
|
|
1716
1887
|
* @template {object} T
|
|
1717
1888
|
* @overload
|
|
1718
1889
|
* @param {TableDefine} tableDefine
|
|
@@ -1723,6 +1894,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1723
1894
|
*/
|
|
1724
1895
|
insert<T extends unknown>(tableDefine: TableDefine, data: T[], keys?: string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1725
1896
|
/**
|
|
1897
|
+
* @deprecated
|
|
1726
1898
|
* @template {object} T
|
|
1727
1899
|
* @overload
|
|
1728
1900
|
* @param {TableDefine} tableDefine
|
|
@@ -1733,6 +1905,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1733
1905
|
*/
|
|
1734
1906
|
insert<T extends unknown>(tableDefine: TableDefine, data: T, keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1735
1907
|
/**
|
|
1908
|
+
* @deprecated
|
|
1736
1909
|
* @template {object} T
|
|
1737
1910
|
* @overload
|
|
1738
1911
|
* @param {TableDefine} tableDefine
|
|
@@ -1743,6 +1916,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1743
1916
|
*/
|
|
1744
1917
|
insert<T extends unknown>(tableDefine: TableDefine, data: T[], keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1745
1918
|
/**
|
|
1919
|
+
* @deprecated
|
|
1746
1920
|
* @template {object} T
|
|
1747
1921
|
* @overload
|
|
1748
1922
|
* @param {TableDefine} tableDefine
|
|
@@ -1753,6 +1927,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1753
1927
|
*/
|
|
1754
1928
|
insert<T extends unknown>(tableDefine: TableDefine, data: T | T[], keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T | T[]>;
|
|
1755
1929
|
/**
|
|
1930
|
+
* @deprecated
|
|
1756
1931
|
* @template {object} T
|
|
1757
1932
|
* @overload
|
|
1758
1933
|
* @param {TableDefine} tableDefine
|
|
@@ -1762,6 +1937,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1762
1937
|
*/
|
|
1763
1938
|
upsert<T extends unknown>(tableDefine: TableDefine, data: T, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1764
1939
|
/**
|
|
1940
|
+
* @deprecated
|
|
1765
1941
|
* @template {object} T
|
|
1766
1942
|
* @overload
|
|
1767
1943
|
* @param {TableDefine} tableDefine
|
|
@@ -1771,6 +1947,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1771
1947
|
*/
|
|
1772
1948
|
upsert<T extends unknown>(tableDefine: TableDefine, data: T[], conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1773
1949
|
/**
|
|
1950
|
+
* @deprecated
|
|
1774
1951
|
* @template {object} T
|
|
1775
1952
|
* @overload
|
|
1776
1953
|
* @param {TableDefine} tableDefine
|
|
@@ -1781,6 +1958,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1781
1958
|
*/
|
|
1782
1959
|
upsert<T extends unknown>(tableDefine: TableDefine, data: T, keys?: string[] | null | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1783
1960
|
/**
|
|
1961
|
+
* @deprecated
|
|
1784
1962
|
* @template {object} T
|
|
1785
1963
|
* @overload
|
|
1786
1964
|
* @param {TableDefine} tableDefine
|
|
@@ -1791,6 +1969,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1791
1969
|
*/
|
|
1792
1970
|
upsert<T extends unknown>(tableDefine: TableDefine, data: T[], keys?: string[] | null | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1793
1971
|
/**
|
|
1972
|
+
* @deprecated
|
|
1794
1973
|
* @template {object} T
|
|
1795
1974
|
* @overload
|
|
1796
1975
|
* @param {TableDefine} tableDefine
|
|
@@ -1802,6 +1981,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1802
1981
|
*/
|
|
1803
1982
|
upsert<T extends unknown>(tableDefine: TableDefine, data: T, keys?: string[] | null | undefined, conflictKeys?: boolean | string[] | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1804
1983
|
/**
|
|
1984
|
+
* @deprecated
|
|
1805
1985
|
* @template {object} T
|
|
1806
1986
|
* @overload
|
|
1807
1987
|
* @param {TableDefine} tableDefine
|
|
@@ -1813,6 +1993,7 @@ declare class Connection<E extends {} = {}> {
|
|
|
1813
1993
|
*/
|
|
1814
1994
|
upsert<T extends unknown>(tableDefine: TableDefine, data: T[], keys?: string[] | null | undefined, conflictKeys?: boolean | string[] | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1815
1995
|
/**
|
|
1996
|
+
* @deprecated
|
|
1816
1997
|
* @template {object} T
|
|
1817
1998
|
* @overload
|
|
1818
1999
|
* @param {TableDefine} tableDefine
|
|
@@ -1822,8 +2003,9 @@ declare class Connection<E extends {} = {}> {
|
|
|
1822
2003
|
* @param {Record<string, SetValue>} [conflictSet]
|
|
1823
2004
|
* @returns {Promise<T>}
|
|
1824
2005
|
*/
|
|
1825
|
-
upsert<T extends unknown>(tableDefine: TableDefine, data: T, keys?: boolean | Record<string, SetValue> |
|
|
2006
|
+
upsert<T extends unknown>(tableDefine: TableDefine, data: T, keys?: boolean | string[] | Record<string, SetValue> | null | undefined, conflictKeys?: boolean | string[] | Record<string, SetValue> | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1826
2007
|
/**
|
|
2008
|
+
* @deprecated
|
|
1827
2009
|
* @template {object} T
|
|
1828
2010
|
* @overload
|
|
1829
2011
|
* @param {TableDefine} tableDefine
|
|
@@ -1833,8 +2015,9 @@ declare class Connection<E extends {} = {}> {
|
|
|
1833
2015
|
* @param {Record<string, SetValue>} [conflictSet]
|
|
1834
2016
|
* @returns {Promise<T[]>}
|
|
1835
2017
|
*/
|
|
1836
|
-
upsert<T extends unknown>(tableDefine: TableDefine, data: T[], keys?: boolean | Record<string, SetValue> |
|
|
2018
|
+
upsert<T extends unknown>(tableDefine: TableDefine, data: T[], keys?: boolean | string[] | Record<string, SetValue> | null | undefined, conflictKeys?: boolean | string[] | Record<string, SetValue> | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1837
2019
|
/**
|
|
2020
|
+
* @deprecated
|
|
1838
2021
|
* @template {object} T
|
|
1839
2022
|
* @overload
|
|
1840
2023
|
* @param {TableDefine} tableDefine
|
|
@@ -1844,37 +2027,41 @@ declare class Connection<E extends {} = {}> {
|
|
|
1844
2027
|
* @param {Record<string, SetValue>} [conflictSet]
|
|
1845
2028
|
* @returns {Promise<T | T[]>}
|
|
1846
2029
|
*/
|
|
1847
|
-
upsert<T extends unknown>(tableDefine: TableDefine, data: T | T[], keys?: boolean | Record<string, SetValue> |
|
|
2030
|
+
upsert<T extends unknown>(tableDefine: TableDefine, data: T | T[], keys?: boolean | string[] | Record<string, SetValue> | null | undefined, conflictKeys?: boolean | string[] | Record<string, SetValue> | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T | T[]>;
|
|
1848
2031
|
/**
|
|
1849
|
-
* @
|
|
2032
|
+
* @deprecated
|
|
2033
|
+
* @param {TableDefine} table
|
|
1850
2034
|
* @param {Record<string, any>} update
|
|
1851
2035
|
* @param {Wheres?} [where]
|
|
1852
2036
|
* @param {boolean | Skip} [skip]
|
|
1853
2037
|
* @returns {Promise<number>}
|
|
1854
2038
|
*/
|
|
1855
|
-
update(
|
|
2039
|
+
update(table: TableDefine, update: Record<string, any>, where?: Wheres | null, skip?: boolean | Skip): Promise<number>;
|
|
1856
2040
|
/**
|
|
2041
|
+
* @deprecated
|
|
1857
2042
|
* @template {Fields<MainFieldType>} T
|
|
1858
|
-
* @param {TableDefine<T>}
|
|
2043
|
+
* @param {TableDefine<T>} table
|
|
1859
2044
|
* @param {Record<string, any>} update
|
|
1860
2045
|
* @param {string[]?} [returning]
|
|
1861
2046
|
* @param {Wheres?} [where]
|
|
1862
2047
|
* @param {boolean | Skip} [skip]
|
|
1863
2048
|
* @returns {Promise<any[]>}
|
|
1864
2049
|
*/
|
|
1865
|
-
updateReturn<T extends Fields<MainFieldType>>(
|
|
2050
|
+
updateReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, update: Record<string, any>, returning?: string[] | null, where?: Wheres | null, skip?: boolean | Skip): Promise<any[]>;
|
|
1866
2051
|
/**
|
|
1867
|
-
* @
|
|
2052
|
+
* @deprecated
|
|
2053
|
+
* @param {TableDefine} table
|
|
1868
2054
|
* @param {string[]} pKeys
|
|
1869
2055
|
* @param {string[]} setKeys
|
|
1870
2056
|
* @param {Record<string, any>[]} list
|
|
1871
2057
|
* @param {boolean | Skip} [skip]
|
|
1872
2058
|
* @returns {Promise<number>}
|
|
1873
2059
|
*/
|
|
1874
|
-
updateMany(
|
|
2060
|
+
updateMany(table: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], skip?: boolean | Skip): Promise<number>;
|
|
1875
2061
|
/**
|
|
2062
|
+
* @deprecated
|
|
1876
2063
|
* @template {Fields<MainFieldType>} T
|
|
1877
|
-
* @param {TableDefine<T>}
|
|
2064
|
+
* @param {TableDefine<T>} table
|
|
1878
2065
|
* @param {string[]} pKeys
|
|
1879
2066
|
* @param {string[]} setKeys
|
|
1880
2067
|
* @param {Record<string, any>[]} list
|
|
@@ -1882,28 +2069,32 @@ declare class Connection<E extends {} = {}> {
|
|
|
1882
2069
|
* @param {boolean | Skip} [skip]
|
|
1883
2070
|
* @returns {Promise<any[]>}
|
|
1884
2071
|
*/
|
|
1885
|
-
updateManyReturn<T extends Fields<MainFieldType>>(
|
|
2072
|
+
updateManyReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, pKeys: string[], setKeys: string[], list: Record<string, any>[], returning?: string[] | null, skip?: boolean | Skip): Promise<any[]>;
|
|
1886
2073
|
/**
|
|
1887
|
-
* @
|
|
2074
|
+
* @deprecated
|
|
2075
|
+
* @param {TableDefine} table
|
|
1888
2076
|
* @param {Wheres?} [where]
|
|
1889
2077
|
* @returns {Promise<number>}
|
|
1890
2078
|
*/
|
|
1891
|
-
delete(
|
|
2079
|
+
delete(table: TableDefine, where?: Wheres | null): Promise<number>;
|
|
1892
2080
|
/**
|
|
2081
|
+
* @deprecated
|
|
1893
2082
|
* @template {Fields<MainFieldType>} T
|
|
1894
|
-
* @param {TableDefine<T>}
|
|
2083
|
+
* @param {TableDefine<T>} table
|
|
1895
2084
|
* @param {string[]?} [returning]
|
|
1896
2085
|
* @param {Wheres?} [where]
|
|
1897
2086
|
* @returns {Promise<any[]>}
|
|
1898
2087
|
*/
|
|
1899
|
-
deleteReturn<T extends Fields<MainFieldType>>(
|
|
2088
|
+
deleteReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, returning?: string[] | null, where?: Wheres | null): Promise<any[]>;
|
|
1900
2089
|
/**
|
|
1901
2090
|
*
|
|
2091
|
+
* @deprecated
|
|
1902
2092
|
* @param {Queryable} queryable
|
|
1903
2093
|
* @returns {Promise<number>}
|
|
1904
2094
|
*/
|
|
1905
2095
|
count(queryable: Queryable): Promise<number>;
|
|
1906
2096
|
/**
|
|
2097
|
+
* @deprecated
|
|
1907
2098
|
* @param {Queryable} queryable
|
|
1908
2099
|
* @returns {Promise<any[]>}
|
|
1909
2100
|
*/
|
|
@@ -1976,6 +2167,10 @@ declare class Connection<E extends {} = {}> {
|
|
|
1976
2167
|
*/
|
|
1977
2168
|
renameTable(table: string, newName: string): Promise<number>;
|
|
1978
2169
|
abort(): boolean;
|
|
2170
|
+
/**
|
|
2171
|
+
* @returns {Promise<Savepoint>}
|
|
2172
|
+
*/
|
|
2173
|
+
savepoint(): Promise<Savepoint>;
|
|
1979
2174
|
/**
|
|
1980
2175
|
* @param {string} table
|
|
1981
2176
|
* @returns {Promise<DBTable?>}
|
|
@@ -2038,8 +2233,7 @@ declare class Subquery {
|
|
|
2038
2233
|
}
|
|
2039
2234
|
|
|
2040
2235
|
type QueryOptions<T extends Fields, TB extends unknown = any> = {
|
|
2041
|
-
|
|
2042
|
-
table?: string | VirtualTable<object> | undefined;
|
|
2236
|
+
table?: string | undefined;
|
|
2043
2237
|
fields: T;
|
|
2044
2238
|
pseudo?: string | undefined;
|
|
2045
2239
|
build?: ((a: object, b?: object | boolean) => TB) | null | undefined;
|
|
@@ -2048,8 +2242,7 @@ type QueryOptions<T extends Fields, TB extends unknown = any> = {
|
|
|
2048
2242
|
* @template {Fields} T
|
|
2049
2243
|
* @template {object} [TB=object]
|
|
2050
2244
|
* @typedef {object} QueryOptions
|
|
2051
|
-
* @property {
|
|
2052
|
-
* @property {string | VirtualTable} [table]
|
|
2245
|
+
* @property {string} [table]
|
|
2053
2246
|
* @property {T} fields
|
|
2054
2247
|
* @property {string} [pseudo]
|
|
2055
2248
|
* @property {((a: object, b?: object | boolean) => TB)?} [build]
|
|
@@ -2075,10 +2268,8 @@ declare class Query<T extends Fields, TB extends unknown = any> extends Subquery
|
|
|
2075
2268
|
* @param {boolean} [noBuild]
|
|
2076
2269
|
*/
|
|
2077
2270
|
constructor(options: QueryOptions<T, TB> | Query<T, TB>, noBuild?: boolean);
|
|
2078
|
-
/** @readonly @type {
|
|
2079
|
-
readonly
|
|
2080
|
-
/** @readonly @type {string | VirtualTable | undefined} */
|
|
2081
|
-
readonly table: string | VirtualTable | undefined;
|
|
2271
|
+
/** @readonly @type {string | undefined} */
|
|
2272
|
+
readonly table: string | undefined;
|
|
2082
2273
|
/** @readonly @type {T} */
|
|
2083
2274
|
readonly fields: T;
|
|
2084
2275
|
/** @readonly @type {string} */
|
|
@@ -2284,6 +2475,91 @@ declare function mergeHooks(...hooks: (Readonly<Partial<Hooks>> | Readonly<Parti
|
|
|
2284
2475
|
*/
|
|
2285
2476
|
declare function bindHooks(hooks: Readonly<Partial<Hooks>>, that: any): Readonly<Partial<Hooks>>;
|
|
2286
2477
|
|
|
2478
|
+
declare function export_default$i<T>(tableDef: TableDefine, data: T): Action<(T extends Destroy ? T : object) | null>;
|
|
2479
|
+
|
|
2480
|
+
declare function export_default$h(queryable: Queryable): Action<number>;
|
|
2481
|
+
|
|
2482
|
+
declare function export_default$g<T extends TableDefine>(model: T, list: object[], skip?: Skip): Action<TableValue<T>[]>;
|
|
2483
|
+
declare function export_default$g<T extends TableDefine>(model: T, value: object, skip?: Skip): Action<T extends Build<infer R> ? R : TableValue<T>>;
|
|
2484
|
+
declare function export_default$g<T extends TableDefine>(model: T, p: object | object[], skip?: Skip): Action<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>;
|
|
2485
|
+
|
|
2486
|
+
declare function export_default$f({ table, connect, fields }: TableDefine, where?: Wheres | null): Action<number>;
|
|
2487
|
+
|
|
2488
|
+
declare function export_default$e({ table, connect, fields }: TableDefine, returning?: string[] | null, where?: Wheres | null): Action<any[]>;
|
|
2489
|
+
|
|
2490
|
+
declare function export_default$d(queryable: Queryable, update?: Record<string, SetValue> | boolean): Action<number>;
|
|
2491
|
+
|
|
2492
|
+
declare function export_default$c<T extends Destroy & PseudoDestroy>(tableDef: TableDefine, data: T, update?: Record<string, any> | boolean): Action<T | null>;
|
|
2493
|
+
declare function export_default$c<T extends Destroy & PseudoDestroy>(tableDef: TableDefine, data: any, update?: Record<string, any> | boolean): Action<T | object | null>;
|
|
2494
|
+
declare function export_default$c(tableDef: TableDefine, data: any, update?: Record<string, any> | boolean): Action<object | null>;
|
|
2495
|
+
|
|
2496
|
+
declare function export_default$b<T extends TableDefine>(sql: T, skip?: Skip): Action<T extends Build<infer R> ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
2497
|
+
|
|
2498
|
+
declare function export_default$a<T extends TableDefine>(sql: T, skip?: Skip): Action<T extends Build<infer R> ? R : T extends TableDefine<infer F> ? FieldValue<F> : never>;
|
|
2499
|
+
|
|
2500
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T[], ignoreConflict?: boolean): Action<T[]>;
|
|
2501
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T, ignoreConflict?: boolean): Action<T>;
|
|
2502
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T | T[], ignoreConflict?: boolean): Action<T | T[]>;
|
|
2503
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T[], keys?: string[], ignoreConflict?: boolean): Action<T[]>;
|
|
2504
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T, keys?: string[], ignoreConflict?: boolean): Action<T>;
|
|
2505
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: string[], ignoreConflict?: boolean): Action<T | T[]>;
|
|
2506
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T[], keys?: string[] | boolean, ignoreConflict?: boolean): Action<T[]>;
|
|
2507
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T, keys?: string[] | boolean, ignoreConflict?: boolean): Action<T>;
|
|
2508
|
+
declare function export_default$9<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: string[] | boolean, ignoreConflict?: boolean): Action<T | T[]>;
|
|
2509
|
+
|
|
2510
|
+
declare function export_default$8<T>(tableDef: TableDefine, data: T, value: Record<string, SetValue>): Action<(T extends PseudoDestroy ? T : object) | null>;
|
|
2511
|
+
|
|
2512
|
+
declare function export_default$7<T>(model: TableDefine, data: T, newData?: Record<string, any> | null, skip?: Skip): Action<(T extends Save ? T : object) | null>;
|
|
2513
|
+
|
|
2514
|
+
declare function export_default$6<T extends TableDefine>(sql: T, fields: string[], skip?: Skip): Action<T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
2515
|
+
|
|
2516
|
+
declare function export_default$5(queryable: Queryable): Action<any[]>;
|
|
2517
|
+
|
|
2518
|
+
declare function export_default$4({ table, connect, fields }: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], skip?: Skip | boolean): Action<number>;
|
|
2519
|
+
|
|
2520
|
+
declare function export_default$3({ table, connect, fields }: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], returning?: string[] | null, skip?: Skip | boolean): Action<any[]>;
|
|
2521
|
+
|
|
2522
|
+
declare function export_default$2({ table, connect, fields }: TableDefine, update: Record<string, any>, where?: Wheres | null, skip?: Skip | boolean): Action<number>;
|
|
2523
|
+
|
|
2524
|
+
declare function export_default$1<T extends Fields<MainFieldType>>({ table, connect, fields }: TableDefine<T>, update: Record<string, any>, returning?: string[] | null, where?: Wheres | null, skip?: Skip | boolean): Action<any[]>;
|
|
2525
|
+
|
|
2526
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T[], conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2527
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T, conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2528
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T | T[], conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2529
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T[], keys?: null | string[], conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2530
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T, keys?: null | string[], conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2531
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: null | string[], conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2532
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T[], keys?: null | string[], conflictKeys?: string[] | boolean, conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2533
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T, keys?: null | string[], conflictKeys?: string[] | boolean, conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2534
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: null | string[], conflictKeys?: string[] | boolean, conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2535
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T[], keys?: null | string[] | boolean | Record<string, SetValue>, conflictKeys?: string[] | boolean | Record<string, SetValue>, conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2536
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T, keys?: null | string[] | boolean | Record<string, SetValue>, conflictKeys?: string[] | boolean | Record<string, SetValue>, conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2537
|
+
declare function export_default<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: null | string[] | boolean | Record<string, SetValue>, conflictKeys?: string[] | boolean | Record<string, SetValue>, conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2538
|
+
|
|
2539
|
+
declare namespace index_d {
|
|
2540
|
+
export {
|
|
2541
|
+
export_default$i as completelyDestroy,
|
|
2542
|
+
export_default$h as count,
|
|
2543
|
+
export_default$g as create,
|
|
2544
|
+
export_default$f as delete,
|
|
2545
|
+
export_default$e as deleteReturn,
|
|
2546
|
+
export_default$c as destroy,
|
|
2547
|
+
export_default$d as destroyMany,
|
|
2548
|
+
export_default$b as find,
|
|
2549
|
+
export_default$a as first,
|
|
2550
|
+
export_default$9 as insert,
|
|
2551
|
+
export_default$8 as pseudoDestroy,
|
|
2552
|
+
export_default$7 as save,
|
|
2553
|
+
export_default$6 as search,
|
|
2554
|
+
export_default$5 as select,
|
|
2555
|
+
export_default$2 as update,
|
|
2556
|
+
export_default$4 as updateList,
|
|
2557
|
+
export_default$3 as updateListReturn,
|
|
2558
|
+
export_default$1 as updateReturn,
|
|
2559
|
+
export_default as upsert,
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2287
2563
|
/**
|
|
2288
2564
|
* @typedef {object} Scene.Define
|
|
2289
2565
|
* @property {string} table
|
|
@@ -2698,4 +2974,5 @@ declare function toBool(v: any): boolean;
|
|
|
2698
2974
|
declare function setDevelopment(d?: boolean): void;
|
|
2699
2975
|
declare let isDevelopment: boolean;
|
|
2700
2976
|
|
|
2701
|
-
export { Build,
|
|
2977
|
+
export { Build, CheckViolationError, Connection, ConnectionError, Create, Destroy, ForeignKeyViolationError, InvalidInputSyntaxError, Model, NotNullViolationError, OperatorMismatchError, PseudoDestroy, Query, Save, Scene, Select, SetValue, Submodel, UniqueViolationError, Where, index_d as actions, afterCreate, afterCreateMany, afterDelete, afterUpdate, beforeCreate, beforeCreateMany, beforeDelete, beforeUpdate, bindHooks, coefficient, column, export_default$i as completelyDestroy, export_default$h as count, export_default$g as create, creating, decrement, defaultValue, field as define, export_default$f as delete, export_default$e as deleteReturn, deleted, deleting, export_default$c as destroy, export_default$d as destroyMany, divide, field$1 as field, export_default$b as find, export_default$a as first, getPrimaryFields, getPrimaryKeys, hooks, immutable, increment, index, export_default$9 as insert, isDevelopment, isPseudo, mergeHooks, model, multiply, now, primary, prop, pseudo, export_default$8 as pseudoDestroy, export_default$7 as save, export_default$6 as search, export_default$5 as select, setDevelopment, sort, model as submodel, toBool, toNot, toPrimaries, toPrimary, uncreatable, undeleted, export_default$2 as update, export_default$4 as updateList, export_default$3 as updateListReturn, export_default$1 as updateReturn, updating, export_default as upsert, uuid, values, where, withDeleted };
|
|
2978
|
+
export type { Action, BaseEnvironment, ClassDecorator, Column, ColumnOptions, ConnectionInterface, Constraint, DBColumn, DBIndex, DBTable, Environment, FieldDecorator, FieldDefine, FieldDefineOption, FieldDefineType, FieldSpecific, FieldSpecificValue, FieldType, FieldTypeDefine, FieldValue, Fields, FindArg, FindRange, GetName, Hook, Hooks, IConnection, IDBTable, Index, IndexInfo, IndexOptions, JOIN, Join, JoinType, LockType, MainFieldType, MaybePromise, MethodDecorator, Options, QueryOptions, Queryable, Savepoint, SelectItem, Skip, Support, TableConnect, TableConnection, TableDefine, TableType, TableValue, ToFieldType, ToType, TransactionFn, TransactionHandler, TransactionHandlerArray, WhereExists, WhereItem, WhereLike, WhereOr, WhereRaw, WhereValue, Wheres };
|