imodel 0.20.0 → 0.20.2
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 +1571 -1944
- package/index.mjs +310 -636
- package/migrate.d.mts +1 -1
- package/migrate.mjs +10 -10
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* imodel v0.20.
|
|
2
|
+
* imodel v0.20.2
|
|
3
3
|
* (c) 2019-2026 猛火Fierflame
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -28,1240 +28,433 @@ declare namespace values {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
type deleted = typeof deleted;
|
|
32
|
+
declare const deleted: unique symbol;
|
|
33
|
+
type undeleted = typeof undeleted;
|
|
34
|
+
declare const undeleted: unique symbol;
|
|
35
|
+
type withDeleted = typeof withDeleted;
|
|
36
|
+
declare const withDeleted: unique symbol;
|
|
37
|
+
type FindRange = deleted | undeleted | withDeleted;
|
|
38
|
+
|
|
39
|
+
/** @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 */
|
|
40
|
+
/** @typedef {{[values.increment]: number | bigint}} SetValue.Increment */
|
|
41
|
+
/** @typedef {{[values.decrement]: number | bigint}} SetValue.Decrement */
|
|
42
|
+
/** @typedef {{[values.multiply]: number | bigint}} SetValue.Multiply */
|
|
43
|
+
/** @typedef {{[values.divide]: number | bigint}} SetValue.Divide */
|
|
44
|
+
/** @typedef {{[values.coefficient]: (number | bigint)[]}} SetValue.Coefficient */
|
|
31
45
|
/**
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
34
|
-
* @param {T} type
|
|
35
|
-
* @param {{
|
|
36
|
-
* nullable?: false;
|
|
37
|
-
* array?: false;
|
|
38
|
-
* default?: ToType<T, false, false> | symbol;
|
|
39
|
-
* [k: string]: any;
|
|
40
|
-
* } & FieldDefineOption} [options]
|
|
41
|
-
* @returns {FieldDecorator<ToType<T, false, false>>}
|
|
46
|
+
* @param {number | bigint} value
|
|
47
|
+
* @returns {SetValue.Increment}
|
|
42
48
|
*/
|
|
43
|
-
declare function
|
|
44
|
-
[k: string]: any;
|
|
45
|
-
nullable?: false;
|
|
46
|
-
array?: false;
|
|
47
|
-
default?: ToType<T, false, false> | symbol;
|
|
48
|
-
} & FieldDefineOption) | undefined): FieldDecorator<ToType<T, false, false>>;
|
|
49
|
+
declare function increment(value: number | bigint): SetValue.Increment;
|
|
49
50
|
/**
|
|
50
|
-
* @
|
|
51
|
-
* @
|
|
52
|
-
* @param {T} type
|
|
53
|
-
* @param {{
|
|
54
|
-
* nullable?: false;
|
|
55
|
-
* array: true;
|
|
56
|
-
* default?: ToType<T, true, false> | symbol;
|
|
57
|
-
* [k: string]: any;
|
|
58
|
-
* } & FieldDefineOption} options
|
|
59
|
-
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
51
|
+
* @param {number | bigint} value
|
|
52
|
+
* @returns {SetValue.Decrement}
|
|
60
53
|
*/
|
|
61
|
-
declare function
|
|
62
|
-
nullable?: false;
|
|
63
|
-
array: true;
|
|
64
|
-
default?: ToType<T, true, false> | symbol;
|
|
65
|
-
[k: string]: any;
|
|
66
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
54
|
+
declare function decrement(value: number | bigint): SetValue.Decrement;
|
|
67
55
|
/**
|
|
68
|
-
* @
|
|
69
|
-
* @
|
|
70
|
-
* @param {T} type
|
|
71
|
-
* @param {true} array
|
|
72
|
-
* @param {{
|
|
73
|
-
* nullable?: false;
|
|
74
|
-
* default?: ToType<T, true, false> | symbol;
|
|
75
|
-
* [k: string]: any;
|
|
76
|
-
* } & FieldDefineOption} options
|
|
77
|
-
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
56
|
+
* @param {number | bigint} value
|
|
57
|
+
* @returns {SetValue.Multiply}
|
|
78
58
|
*/
|
|
79
|
-
declare function
|
|
80
|
-
nullable?: false;
|
|
81
|
-
default?: ToType<T, true, false> | symbol;
|
|
82
|
-
[k: string]: any;
|
|
83
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
59
|
+
declare function multiply(value: number | bigint): SetValue.Multiply;
|
|
84
60
|
/**
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
87
|
-
* @param {T} type
|
|
88
|
-
* @param {{
|
|
89
|
-
* nullable: true;
|
|
90
|
-
* array?: false;
|
|
91
|
-
* default?: ToType<T, false, true> | symbol;
|
|
92
|
-
* [k: string]: any;
|
|
93
|
-
* } & FieldDefineOption} options
|
|
94
|
-
* @returns {FieldDecorator<ToType<T, false, true>>}
|
|
61
|
+
* @param {number | bigint} value
|
|
62
|
+
* @returns {SetValue.Divide}
|
|
95
63
|
*/
|
|
96
|
-
declare function
|
|
97
|
-
nullable: true;
|
|
98
|
-
array?: false;
|
|
99
|
-
default?: ToType<T, false, true> | symbol;
|
|
100
|
-
[k: string]: any;
|
|
101
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, false, true>>;
|
|
64
|
+
declare function divide(value: number | bigint): SetValue.Divide;
|
|
102
65
|
/**
|
|
103
|
-
* @
|
|
104
|
-
* @
|
|
105
|
-
* @param {T} type
|
|
106
|
-
* @param {{
|
|
107
|
-
* nullable: true;
|
|
108
|
-
* array: true;
|
|
109
|
-
* default?: ToType<T, true, true> | symbol;
|
|
110
|
-
* [k: string]: any;
|
|
111
|
-
* } & FieldDefineOption} options
|
|
112
|
-
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
66
|
+
* @param {...number | bigint} value
|
|
67
|
+
* @returns {SetValue.Coefficient}
|
|
113
68
|
*/
|
|
114
|
-
declare function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
69
|
+
declare function coefficient(...value: (number | bigint)[]): SetValue.Coefficient;
|
|
70
|
+
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)[];
|
|
71
|
+
declare namespace SetValue {
|
|
72
|
+
type Increment = {
|
|
73
|
+
[increment$1]: number | bigint;
|
|
74
|
+
};
|
|
75
|
+
type Decrement = {
|
|
76
|
+
[decrement$1]: number | bigint;
|
|
77
|
+
};
|
|
78
|
+
type Multiply = {
|
|
79
|
+
[multiply$1]: number | bigint;
|
|
80
|
+
};
|
|
81
|
+
type Divide = {
|
|
82
|
+
[divide$1]: number | bigint;
|
|
83
|
+
};
|
|
84
|
+
type Coefficient = {
|
|
85
|
+
[coefficient$1]: (number | bigint)[];
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type Select = {
|
|
90
|
+
field: string;
|
|
91
|
+
table?: string;
|
|
92
|
+
fn?: string;
|
|
93
|
+
};
|
|
94
|
+
declare namespace Select {
|
|
95
|
+
type Param = boolean | string | Select;
|
|
96
|
+
}
|
|
97
|
+
type JoinType = 'left' | 'right' | 'inner' | 'full';
|
|
98
|
+
interface Join<T extends TableDefine = TableDefine> {
|
|
99
|
+
type: JoinType;
|
|
100
|
+
table: T;
|
|
101
|
+
/** 关联项目 { [this table field]: base table field } */
|
|
102
|
+
on: {
|
|
103
|
+
[k: string]: string;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
interface Options {
|
|
107
|
+
distinct?: boolean;
|
|
108
|
+
range?: FindRange;
|
|
109
|
+
select?: Record<string, Select> | null;
|
|
110
|
+
/** 排序配置,true 表示逆序 */
|
|
111
|
+
sort?: [field: string, desc: boolean][];
|
|
112
|
+
/** 匹配信息 */
|
|
113
|
+
where: WhereValue[];
|
|
114
|
+
/** 偏移量 */
|
|
115
|
+
offset?: number;
|
|
116
|
+
/** 最大返回数 */
|
|
117
|
+
limit?: number;
|
|
118
|
+
update?: Record<string, SetValue>;
|
|
119
|
+
alias?: string;
|
|
120
|
+
group?: string[];
|
|
121
|
+
lock?: 'S' | 'X' | null;
|
|
122
|
+
}
|
|
123
|
+
interface Queryable<T extends Fields = Fields> extends TableDefine<T> {
|
|
124
|
+
readonly options: Options;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface ColumnOptions<T = unknown> extends FieldDefineOption {
|
|
128
|
+
/**
|
|
129
|
+
* 是否可为空
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
nullable?: boolean;
|
|
133
|
+
/** 是否为数组格式 */
|
|
134
|
+
array?: boolean;
|
|
135
|
+
/** 默认值 */
|
|
136
|
+
default?: T extends never ? never : T;
|
|
137
|
+
}
|
|
138
|
+
interface Column<T> extends ColumnOptions<T> {
|
|
139
|
+
column: string;
|
|
140
|
+
type: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare class ConnectionError extends Error {
|
|
144
|
+
/**
|
|
145
|
+
* @param {string} code - 自定义通用错误码 (例如 constraint:unique)
|
|
146
|
+
* @param {string} message - 原始错误信息或自定义信息
|
|
147
|
+
*/
|
|
148
|
+
constructor(code: string, message: string);
|
|
149
|
+
/** @type {string} */
|
|
150
|
+
code: string;
|
|
151
|
+
}
|
|
120
152
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @param {true} array
|
|
125
|
-
* @param {{
|
|
126
|
-
* nullable: true;
|
|
127
|
-
* default?: ToType<T, true, true> | symbol;
|
|
128
|
-
* [k: string]: any;
|
|
129
|
-
* } & FieldDefineOption} options
|
|
130
|
-
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
153
|
+
* 非空约束违规
|
|
154
|
+
* 对应 PG 23502 / MySQL 1048
|
|
155
|
+
* 场景:插入数据时,必填字段为空
|
|
131
156
|
*/
|
|
132
|
-
declare
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
157
|
+
declare class NotNullViolationError extends ConnectionError {
|
|
158
|
+
/** @type {string} */
|
|
159
|
+
table: string;
|
|
160
|
+
/** @type {string} */
|
|
161
|
+
column: string;
|
|
162
|
+
}
|
|
137
163
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* @param {T} type
|
|
142
|
-
* @param {{
|
|
143
|
-
* nullable: true;
|
|
144
|
-
* array: A;
|
|
145
|
-
* default?: ToType<T, A, true> | symbol;
|
|
146
|
-
* [k: string]: any;
|
|
147
|
-
* } & FieldDefineOption} options
|
|
148
|
-
* @returns {FieldDecorator<ToType<T, A, true>>}
|
|
164
|
+
* 唯一性约束违规
|
|
165
|
+
* 对应 PG 23505 / MySQL 1062
|
|
166
|
+
* 支持单字段和多字段组合冲突
|
|
149
167
|
*/
|
|
150
|
-
declare
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
168
|
+
declare class UniqueViolationError extends ConnectionError {
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} table - 表名
|
|
171
|
+
* @param {string | string[]} columns - 冲突的列名(可以是字符串或字符串数组)
|
|
172
|
+
* @param {any} [values] - 导致冲突的值(可选,多字段时为对象或数组)
|
|
173
|
+
*/
|
|
174
|
+
constructor(table: string, columns: string | string[], values?: any);
|
|
175
|
+
/** @type {string} */
|
|
176
|
+
table: string;
|
|
177
|
+
/** @type {string[]} */
|
|
178
|
+
columns: string[];
|
|
179
|
+
/** @type {any} */
|
|
180
|
+
values: any;
|
|
181
|
+
}
|
|
156
182
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* @param {T} type
|
|
161
|
-
* @param {{
|
|
162
|
-
* nullable?: false;
|
|
163
|
-
* array: A;
|
|
164
|
-
* default?: ToType<T, A, false> | symbol;
|
|
165
|
-
* [k: string]: any;
|
|
166
|
-
* } & FieldDefineOption} options
|
|
167
|
-
* @returns {FieldDecorator<ToType<T, A, false>>}
|
|
168
|
-
*/
|
|
169
|
-
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
170
|
-
nullable?: false;
|
|
171
|
-
array: A;
|
|
172
|
-
default?: ToType<T, A, false> | symbol;
|
|
173
|
-
[k: string]: any;
|
|
174
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, A, false>>;
|
|
175
|
-
/**
|
|
176
|
-
* @template {keyof FieldType} T
|
|
177
|
-
* @template {boolean} N
|
|
178
|
-
* @overload
|
|
179
|
-
* @param {T} type
|
|
180
|
-
* @param {{
|
|
181
|
-
* nullable: N;
|
|
182
|
-
* array?: false;
|
|
183
|
-
* default?: ToType<T, false, N> | symbol;
|
|
184
|
-
* [k: string]: any;
|
|
185
|
-
* } & FieldDefineOption} options
|
|
186
|
-
* @returns {FieldDecorator<ToType<T, false, N>>}
|
|
187
|
-
*/
|
|
188
|
-
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
189
|
-
nullable: N;
|
|
190
|
-
array?: false;
|
|
191
|
-
default?: ToType<T, false, N> | symbol;
|
|
192
|
-
[k: string]: any;
|
|
193
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, false, N>>;
|
|
194
|
-
/**
|
|
195
|
-
* @template {keyof FieldType} T
|
|
196
|
-
* @template {boolean} N
|
|
197
|
-
* @overload
|
|
198
|
-
* @param {T} type
|
|
199
|
-
* @param {{
|
|
200
|
-
* nullable: N;
|
|
201
|
-
* array: true;
|
|
202
|
-
* default?: ToType<T, true, N> | symbol;
|
|
203
|
-
* [k: string]: any;
|
|
204
|
-
* } & FieldDefineOption} options
|
|
205
|
-
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
206
|
-
*/
|
|
207
|
-
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
208
|
-
nullable: N;
|
|
209
|
-
array: true;
|
|
210
|
-
default?: ToType<T, true, N> | symbol;
|
|
211
|
-
[k: string]: any;
|
|
212
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
213
|
-
/**
|
|
214
|
-
* @template {keyof FieldType} T
|
|
215
|
-
* @template {boolean} N
|
|
216
|
-
* @overload
|
|
217
|
-
* @param {T} type
|
|
218
|
-
* @param {true} array
|
|
219
|
-
* @param {{
|
|
220
|
-
* nullable: N;
|
|
221
|
-
* default?: ToType<T, true, N> | symbol;
|
|
222
|
-
* [k: string]: any;
|
|
223
|
-
* } & FieldDefineOption} options
|
|
224
|
-
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
225
|
-
*/
|
|
226
|
-
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, array: true, options: {
|
|
227
|
-
nullable: N;
|
|
228
|
-
default?: ToType<T, true, N> | symbol;
|
|
229
|
-
[k: string]: any;
|
|
230
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
231
|
-
/**
|
|
232
|
-
* @template {keyof FieldType} T
|
|
233
|
-
* @template {boolean} A
|
|
234
|
-
* @template {boolean} N
|
|
235
|
-
* @overload
|
|
236
|
-
* @param {T} type
|
|
237
|
-
* @param {{
|
|
238
|
-
* nullable: N;
|
|
239
|
-
* array: A;
|
|
240
|
-
* default?: ToType<T, A, N> | symbol;
|
|
241
|
-
* [k: string]: any;
|
|
242
|
-
* } & FieldDefineOption} options
|
|
243
|
-
* @returns {FieldDecorator<ToType<T, A, N>>}
|
|
244
|
-
*/
|
|
245
|
-
declare function field$1<T extends keyof FieldType, A extends boolean, N extends boolean>(type: T, options: {
|
|
246
|
-
nullable: N;
|
|
247
|
-
array: A;
|
|
248
|
-
default?: ToType<T, A, N> | symbol;
|
|
249
|
-
[k: string]: any;
|
|
250
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, A, N>>;
|
|
251
|
-
/**
|
|
252
|
-
* @template {keyof FieldType} T
|
|
253
|
-
* @overload
|
|
254
|
-
* @param {T} type
|
|
255
|
-
* @param {{
|
|
256
|
-
* nullable?: boolean;
|
|
257
|
-
* array?: boolean;
|
|
258
|
-
* default?: ToType<T, boolean, boolean> | symbol;
|
|
259
|
-
* [k: string]: any;
|
|
260
|
-
* } & FieldDefineOption} options
|
|
261
|
-
* @returns {FieldDecorator<ToType<T, boolean, boolean>>}
|
|
183
|
+
* 外键约束违规
|
|
184
|
+
* 对应 PG 23503 / MySQL 1452
|
|
185
|
+
* 场景:插入了一个不存在的 user_id
|
|
262
186
|
*/
|
|
263
|
-
declare
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
/** @
|
|
187
|
+
declare class ForeignKeyViolationError extends ConnectionError {
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} table - 当前操作的表
|
|
190
|
+
* @param {string | string[]} columns - 当前操作的外键列
|
|
191
|
+
* @param {string} [referencedTable] - 被引用的父表
|
|
192
|
+
*/
|
|
193
|
+
constructor(table: string, columns: string | string[], referencedTable?: string);
|
|
194
|
+
/** @type {string} */
|
|
195
|
+
table: string;
|
|
196
|
+
/** @type {string[]} */
|
|
197
|
+
columns: string[];
|
|
198
|
+
/** @type {string} */
|
|
199
|
+
referencedTable: string;
|
|
200
|
+
}
|
|
271
201
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* @param {boolean} [end]
|
|
276
|
-
* @returns {FieldDecorator<any>}
|
|
202
|
+
* 检查约束违规
|
|
203
|
+
* 对应 PG 23514
|
|
204
|
+
* 场景:年龄字段要求 > 0,但插入了 -5
|
|
277
205
|
*/
|
|
278
|
-
declare
|
|
279
|
-
|
|
280
|
-
|
|
206
|
+
declare class CheckViolationError extends ConnectionError {
|
|
207
|
+
/**
|
|
208
|
+
* @param {string} table - 当前操作的表
|
|
209
|
+
* @param {string} [constraint] - 当前操作的外键列
|
|
210
|
+
*/
|
|
211
|
+
constructor(table: string, constraint?: string);
|
|
212
|
+
/** @type {string} */
|
|
213
|
+
table: string;
|
|
214
|
+
/** @type {string} */
|
|
215
|
+
constraint: string;
|
|
216
|
+
}
|
|
281
217
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
218
|
+
* 无效的类型输入语法错误
|
|
219
|
+
* 对应 PG 22P02
|
|
220
|
+
* 场景:无效的 UUID、日期格式错误等
|
|
285
221
|
*/
|
|
286
|
-
declare
|
|
287
|
-
|
|
288
|
-
|
|
222
|
+
declare class InvalidInputSyntaxError extends ConnectionError {
|
|
223
|
+
/**
|
|
224
|
+
* @param {string} message - 目标数据类型
|
|
225
|
+
*/
|
|
226
|
+
constructor(message: string);
|
|
227
|
+
}
|
|
289
228
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
229
|
+
* 操作符不匹配错误
|
|
230
|
+
* 对应 PG 42883
|
|
231
|
+
* 场景:uuid = integer 等类型不兼容的操作
|
|
293
232
|
*/
|
|
294
|
-
declare
|
|
233
|
+
declare class OperatorMismatchError extends ConnectionError {
|
|
234
|
+
/**
|
|
235
|
+
* @param {string} message
|
|
236
|
+
*/
|
|
237
|
+
constructor(message: string);
|
|
238
|
+
}
|
|
295
239
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
240
|
+
type errors_CheckViolationError = CheckViolationError;
|
|
241
|
+
declare const errors_CheckViolationError: typeof CheckViolationError;
|
|
242
|
+
type errors_ConnectionError = ConnectionError;
|
|
243
|
+
declare const errors_ConnectionError: typeof ConnectionError;
|
|
244
|
+
type errors_ForeignKeyViolationError = ForeignKeyViolationError;
|
|
245
|
+
declare const errors_ForeignKeyViolationError: typeof ForeignKeyViolationError;
|
|
246
|
+
type errors_InvalidInputSyntaxError = InvalidInputSyntaxError;
|
|
247
|
+
declare const errors_InvalidInputSyntaxError: typeof InvalidInputSyntaxError;
|
|
248
|
+
type errors_NotNullViolationError = NotNullViolationError;
|
|
249
|
+
declare const errors_NotNullViolationError: typeof NotNullViolationError;
|
|
250
|
+
type errors_OperatorMismatchError = OperatorMismatchError;
|
|
251
|
+
declare const errors_OperatorMismatchError: typeof OperatorMismatchError;
|
|
252
|
+
type errors_UniqueViolationError = UniqueViolationError;
|
|
253
|
+
declare const errors_UniqueViolationError: typeof UniqueViolationError;
|
|
254
|
+
declare namespace errors {
|
|
255
|
+
export {
|
|
256
|
+
errors_CheckViolationError as CheckViolationError,
|
|
257
|
+
errors_ConnectionError as ConnectionError,
|
|
258
|
+
errors_ForeignKeyViolationError as ForeignKeyViolationError,
|
|
259
|
+
errors_InvalidInputSyntaxError as InvalidInputSyntaxError,
|
|
260
|
+
errors_NotNullViolationError as NotNullViolationError,
|
|
261
|
+
errors_OperatorMismatchError as OperatorMismatchError,
|
|
262
|
+
errors_UniqueViolationError as UniqueViolationError,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
299
265
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
266
|
+
interface BaseEnvironment {
|
|
267
|
+
isDevelopment: boolean;
|
|
268
|
+
values: typeof values;
|
|
269
|
+
errors: typeof errors;
|
|
270
|
+
}
|
|
271
|
+
interface Environment<T extends object> extends BaseEnvironment {
|
|
272
|
+
readonly transaction: T | null;
|
|
273
|
+
}
|
|
303
274
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
* @returns {FieldDecorator<any>}
|
|
325
|
-
*/
|
|
326
|
-
declare function index(unique?: boolean | undefined): FieldDecorator<any>;
|
|
275
|
+
declare const Destroy: unique symbol;
|
|
276
|
+
interface Destroy {
|
|
277
|
+
[Destroy](connection: Connection, run: (data: any) => Promise<object | null>, table: TableDefine<Fields<MainFieldType>>): PromiseLike<this | null>;
|
|
278
|
+
}
|
|
279
|
+
declare const PseudoDestroy: unique symbol;
|
|
280
|
+
interface PseudoDestroy {
|
|
281
|
+
[PseudoDestroy](connection: Connection, update: Record<string, SetValue>, run: (data: any) => Promise<object | null>, table: TableDefine<Fields<MainFieldType>>): PromiseLike<this | null>;
|
|
282
|
+
}
|
|
283
|
+
declare const Save: unique symbol;
|
|
284
|
+
interface Save {
|
|
285
|
+
[Save](connection: Connection, run: (data: any, newData?: any) => Promise<object | null>, newData: Record<string, any> | null, table: TableDefine): PromiseLike<this | null>;
|
|
286
|
+
}
|
|
287
|
+
declare const Create: unique symbol;
|
|
288
|
+
interface Create<T = unknown> {
|
|
289
|
+
[Create](connection: Connection, data: object, run: (data: any, that: any) => Promise<object>, table: TableDefine): PromiseLike<T>;
|
|
290
|
+
}
|
|
291
|
+
declare const Build: unique symbol;
|
|
292
|
+
interface Build<T = unknown> {
|
|
293
|
+
[Build](data: object, others: object | boolean): T;
|
|
294
|
+
}
|
|
327
295
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
|
|
339
|
-
* @param {string} pseudo
|
|
340
|
-
* @returns {ClassDecorator}
|
|
341
|
-
*/
|
|
342
|
-
declare function pseudo(pseudo: string): ClassDecorator;
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* @template T
|
|
346
|
-
* @overload
|
|
347
|
-
* @param {now} value
|
|
348
|
-
* @returns {FieldDecorator<string | Date>}
|
|
349
|
-
*/
|
|
350
|
-
declare function defaultValue<T>(value: typeof now): FieldDecorator<string | Date>;
|
|
351
|
-
/**
|
|
352
|
-
* @template T
|
|
353
|
-
* @overload
|
|
354
|
-
* @param {uuid} value
|
|
355
|
-
* @returns {FieldDecorator<string>}
|
|
356
|
-
*/
|
|
357
|
-
declare function defaultValue<T>(value: typeof uuid): FieldDecorator<string>;
|
|
358
|
-
/**
|
|
359
|
-
* @template T
|
|
360
|
-
* @overload
|
|
361
|
-
* @param {T} value
|
|
362
|
-
* @returns {FieldDecorator<T>}
|
|
363
|
-
*/
|
|
364
|
-
declare function defaultValue<T>(value: T): FieldDecorator<T>;
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
*
|
|
368
|
-
* @overload
|
|
369
|
-
* @param {string} table
|
|
370
|
-
* @returns {ClassDecorator}
|
|
371
|
-
*/
|
|
372
|
-
declare function model(table: string): ClassDecorator;
|
|
373
|
-
/**
|
|
374
|
-
* @template {Record<string, any>} T
|
|
375
|
-
* @overload
|
|
376
|
-
* @param {TableDefine & {new(...a: any): T}} type
|
|
377
|
-
* @param {Record<string, Constraint>} constraints
|
|
378
|
-
* @param {true} array
|
|
379
|
-
* @param {FieldDefineOption} [options]
|
|
380
|
-
* @returns {FieldDecorator<T[]>}
|
|
381
|
-
*/
|
|
382
|
-
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
383
|
-
new (...a: any): T;
|
|
384
|
-
}, constraints: Record<string, Constraint>, array: true, options?: FieldDefineOption | undefined): FieldDecorator<T[]>;
|
|
385
|
-
/**
|
|
386
|
-
* @template {Record<string, any>} T
|
|
387
|
-
* @overload
|
|
388
|
-
* @param {TableDefine & {new(...a: any): T}} type
|
|
389
|
-
* @param {Record<string, Constraint>} constraints
|
|
390
|
-
* @param {false} [array]
|
|
391
|
-
* @param {FieldDefineOption} [options]
|
|
392
|
-
* @returns {FieldDecorator<T>}
|
|
393
|
-
*/
|
|
394
|
-
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
395
|
-
new (...a: any): T;
|
|
396
|
-
}, constraints: Record<string, Constraint>, array?: false | undefined, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
397
|
-
/**
|
|
398
|
-
* @template {Record<string, any>} T
|
|
399
|
-
* @overload
|
|
400
|
-
* @param {TableDefine & {new(...a: any): T}} type
|
|
401
|
-
* @param {Record<string, Constraint>} constraints
|
|
402
|
-
* @param {FieldDefineOption} [options]
|
|
403
|
-
* @returns {FieldDecorator<T>}
|
|
404
|
-
*/
|
|
405
|
-
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
406
|
-
new (...a: any): T;
|
|
407
|
-
}, constraints: Record<string, Constraint>, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
408
|
-
/**
|
|
409
|
-
* @template {Record<string, any>} T
|
|
410
|
-
* @template {boolean} [A=boolean]
|
|
411
|
-
* @overload
|
|
412
|
-
* @param {TableDefine & {new(...a: any): T}} type
|
|
413
|
-
* @param {Record<string, Constraint>} constraints
|
|
414
|
-
* @param {A} array
|
|
415
|
-
* @param {FieldDefineOption} [options]
|
|
416
|
-
* @returns {FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>}
|
|
417
|
-
*/
|
|
418
|
-
declare function model<T extends Record<string, any>, A extends boolean = boolean>(type: TableDefine & {
|
|
419
|
-
new (...a: any): T;
|
|
420
|
-
}, constraints: Record<string, Constraint>, array: A, options?: FieldDefineOption | undefined): FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>;
|
|
421
|
-
/**
|
|
422
|
-
* @template {object} T
|
|
423
|
-
* @overload
|
|
424
|
-
* @param {TableDefine} type
|
|
425
|
-
* @param {Record<string, Constraint>} constraints
|
|
426
|
-
* @param {true} array
|
|
427
|
-
* @param {FieldDefineOption} [options]
|
|
428
|
-
* @returns {FieldDecorator<T[]>}
|
|
429
|
-
*/
|
|
430
|
-
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, array: true, options?: FieldDefineOption | undefined): FieldDecorator<T[]>;
|
|
431
|
-
/**
|
|
432
|
-
* @template {object} T
|
|
433
|
-
* @overload
|
|
434
|
-
* @param {TableDefine} type
|
|
435
|
-
* @param {Record<string, Constraint>} constraints
|
|
436
|
-
* @param {false} [array]
|
|
437
|
-
* @param {FieldDefineOption} [options]
|
|
438
|
-
* @returns {FieldDecorator<T>}
|
|
439
|
-
*/
|
|
440
|
-
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, array?: false | undefined, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
441
|
-
/**
|
|
442
|
-
* @template {object} T
|
|
443
|
-
* @overload
|
|
444
|
-
* @param {TableDefine} type
|
|
445
|
-
* @param {Record<string, Constraint>} constraints
|
|
446
|
-
* @param {FieldDefineOption} [options]
|
|
447
|
-
* @returns {FieldDecorator<T>}
|
|
448
|
-
*/
|
|
449
|
-
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
450
|
-
/**
|
|
451
|
-
* @template {object} T
|
|
452
|
-
* @template {boolean} [A=boolean]
|
|
453
|
-
* @overload
|
|
454
|
-
* @param {TableDefine} type
|
|
455
|
-
* @param {Record<string, Constraint>} constraints
|
|
456
|
-
* @param {A} array
|
|
457
|
-
* @param {FieldDefineOption} [options]
|
|
458
|
-
* @returns {FieldDecorator<A extends false ? T :A extends true ? T[] : T | T[]>}
|
|
459
|
-
*/
|
|
460
|
-
declare function model<T extends Record<string, any>, A extends boolean = boolean>(type: TableDefine, constraints: Record<string, Constraint>, array: A, options?: FieldDefineOption | undefined): FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>;
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* @param {number} [size]
|
|
464
|
-
* @returns {FieldDecorator<Date?>}
|
|
465
|
-
*/
|
|
466
|
-
declare function creating(size?: number): FieldDecorator<Date | null>;
|
|
467
|
-
/**
|
|
468
|
-
* @param {number} [size]
|
|
469
|
-
* @returns {FieldDecorator<Date?>}
|
|
470
|
-
*/
|
|
471
|
-
declare function updating(size?: number): FieldDecorator<Date | null>;
|
|
472
|
-
/**
|
|
473
|
-
* @param {number} [size]
|
|
474
|
-
* @returns {FieldDecorator<Date?>}
|
|
475
|
-
*/
|
|
476
|
-
declare function deleting(size?: number): FieldDecorator<Date | null>;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* @overload
|
|
480
|
-
* @param {Partial<Hooks>} hook
|
|
481
|
-
* @param {boolean} [approach] 插入位置是否为更靠近执行的位置
|
|
482
|
-
* @returns {ClassDecorator}
|
|
483
|
-
*/
|
|
484
|
-
declare function hooks(hook: Partial<Hooks>, approach?: boolean | undefined): ClassDecorator;
|
|
485
|
-
/**
|
|
486
|
-
* @overload
|
|
487
|
-
* @param {Function} Model
|
|
488
|
-
* @param {Partial<Hooks>} hook
|
|
489
|
-
* @param {boolean} [approach] 插入位置是否为更靠近执行的位置
|
|
490
|
-
* @returns {void}
|
|
491
|
-
*/
|
|
492
|
-
declare function hooks(Model: Function, hook: Partial<Hooks>, approach?: boolean | undefined): void;
|
|
493
|
-
/** @type {Hook<Hooks['where']>} */
|
|
494
|
-
declare const where: Hook<Hooks["where"]>;
|
|
495
|
-
/** @type {Hook<Hooks['beforeCreateMany']>} */
|
|
496
|
-
declare const beforeCreateMany: Hook<Hooks["beforeCreateMany"]>;
|
|
497
|
-
/** @type {Hook<Hooks['afterCreateMany']>} */
|
|
498
|
-
declare const afterCreateMany: Hook<Hooks["afterCreateMany"]>;
|
|
499
|
-
/** @type {Hook<Hooks['beforeCreate']>} */
|
|
500
|
-
declare const beforeCreate: Hook<Hooks["beforeCreate"]>;
|
|
501
|
-
/** @type {Hook<Hooks['afterCreate']>} */
|
|
502
|
-
declare const afterCreate: Hook<Hooks["afterCreate"]>;
|
|
503
|
-
/** @type {Hook<Hooks['beforeUpdate']>} */
|
|
504
|
-
declare const beforeUpdate: Hook<Hooks["beforeUpdate"]>;
|
|
505
|
-
/** @type {Hook<Hooks['afterUpdate']>} */
|
|
506
|
-
declare const afterUpdate: Hook<Hooks["afterUpdate"]>;
|
|
507
|
-
/** @type {Hook<Hooks['beforeDelete']>} */
|
|
508
|
-
declare const beforeDelete: Hook<Hooks["beforeDelete"]>;
|
|
509
|
-
/** @type {Hook<Hooks['afterDelete']>} */
|
|
510
|
-
declare const afterDelete: Hook<Hooks["afterDelete"]>;
|
|
511
|
-
|
|
512
|
-
type ClassDecorator = (val: Function, ctx: ClassDecoratorContext) => any;
|
|
513
|
-
type FieldDecorator<T> = (val: {
|
|
514
|
-
get(): T;
|
|
515
|
-
set(v: T): void;
|
|
516
|
-
}, ctx: ClassAccessorDecoratorContext) => any;
|
|
517
|
-
type MethodDecorator<T extends Function> = (val: T, ctx: ClassMethodDecoratorContext<any, T>) => any;
|
|
518
|
-
|
|
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;
|
|
296
|
+
type TableType = '' | 'table' | 'view';
|
|
297
|
+
interface FindArg {
|
|
298
|
+
/** 排序配置,true 表示逆序 */
|
|
299
|
+
sort?: [field: string, desc: boolean][];
|
|
300
|
+
/** 匹配信息 */
|
|
301
|
+
where: WhereValue[];
|
|
302
|
+
select: [string, Select][];
|
|
303
|
+
/** 偏移量 */
|
|
304
|
+
offset?: number;
|
|
305
|
+
/** 最大返回数 */
|
|
306
|
+
limit?: number;
|
|
527
307
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
* 对应 PG 23502 / MySQL 1048
|
|
531
|
-
* 场景:插入数据时,必填字段为空
|
|
532
|
-
*/
|
|
533
|
-
declare class NotNullViolationError extends ConnectionError {
|
|
534
|
-
/** @type {string} */
|
|
308
|
+
interface JOIN {
|
|
309
|
+
type?: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS';
|
|
535
310
|
table: string;
|
|
536
|
-
|
|
537
|
-
|
|
311
|
+
columns: Record<string, DBColumn>;
|
|
312
|
+
alias?: string;
|
|
313
|
+
condition?: WhereValue[];
|
|
538
314
|
}
|
|
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} */
|
|
315
|
+
type LockType = 'S' | 'X';
|
|
316
|
+
interface IDBTable {
|
|
552
317
|
table: string;
|
|
553
|
-
|
|
554
|
-
columns: string[];
|
|
555
|
-
/** @type {any} */
|
|
556
|
-
values: any;
|
|
318
|
+
columns: Record<string, DBColumn>;
|
|
557
319
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
*/
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
columns: string[];
|
|
574
|
-
/** @type {string} */
|
|
575
|
-
referencedTable: string;
|
|
320
|
+
interface SelectItem extends IDBTable {
|
|
321
|
+
distinct?: boolean;
|
|
322
|
+
select: [string, Select][];
|
|
323
|
+
alias?: string;
|
|
324
|
+
/** 匹配信息 */
|
|
325
|
+
where: WhereValue[];
|
|
326
|
+
group: string[];
|
|
327
|
+
having: WhereValue[];
|
|
328
|
+
/** 排序配置,true 表示逆序 */
|
|
329
|
+
sort: [field: string, desc: boolean][];
|
|
330
|
+
/** 偏移量 */
|
|
331
|
+
offset?: number;
|
|
332
|
+
/** 最大返回数 */
|
|
333
|
+
limit?: number;
|
|
334
|
+
lock?: LockType | null;
|
|
576
335
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
*/
|
|
587
|
-
constructor(table: string, constraint?: string);
|
|
588
|
-
/** @type {string} */
|
|
589
|
-
table: string;
|
|
590
|
-
/** @type {string} */
|
|
591
|
-
constraint: string;
|
|
336
|
+
type GetName = (table?: string) => string;
|
|
337
|
+
interface DBColumn {
|
|
338
|
+
type: string;
|
|
339
|
+
size?: number;
|
|
340
|
+
scale?: number;
|
|
341
|
+
default?: any;
|
|
342
|
+
nullable?: boolean;
|
|
343
|
+
array?: boolean;
|
|
344
|
+
primary?: number;
|
|
592
345
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
declare class InvalidInputSyntaxError extends ConnectionError {
|
|
599
|
-
/**
|
|
600
|
-
* @param {string} message - 目标数据类型
|
|
601
|
-
*/
|
|
602
|
-
constructor(message: string);
|
|
346
|
+
interface DBIndex {
|
|
347
|
+
fields: string[];
|
|
348
|
+
includes?: string[];
|
|
349
|
+
unique?: boolean;
|
|
350
|
+
name?: string;
|
|
603
351
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
declare class OperatorMismatchError extends ConnectionError {
|
|
610
|
-
/**
|
|
611
|
-
* @param {string} message
|
|
612
|
-
*/
|
|
613
|
-
constructor(message: string);
|
|
352
|
+
interface DBTable {
|
|
353
|
+
table: string;
|
|
354
|
+
fields: Record<string, DBColumn>;
|
|
355
|
+
indexes?: DBIndex[];
|
|
356
|
+
primary?: string;
|
|
614
357
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
-
};
|
|
358
|
+
interface Savepoint {
|
|
359
|
+
readonly name: string;
|
|
360
|
+
rollback(): Promise<void>;
|
|
361
|
+
release(): Promise<void>;
|
|
362
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
640
363
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
364
|
+
interface ConnectionInterface {
|
|
365
|
+
build<T extends Fields>(build: Build<T>, data: object, saved?: boolean): T;
|
|
366
|
+
build<T extends Fields>(table: TableDefine<T>, data: object, saved?: boolean): FieldValue<T>;
|
|
367
|
+
build(p: Build | TableDefine, data: object, saved?: boolean): any;
|
|
368
|
+
build<T extends Fields>(build: Build<T>, data: object, unsaved?: object): T;
|
|
369
|
+
build<T extends Fields>(table: TableDefine<T>, data: object, unsaved?: object): FieldValue<T>;
|
|
370
|
+
build(p: Build | TableDefine, data: object, unsaved?: object): any;
|
|
371
|
+
build<T extends Fields>(build: Build<T>, data: object, saved?: object | boolean): T;
|
|
372
|
+
build<T extends Fields>(table: TableDefine<T>, data: object, saved?: object | boolean): FieldValue<T>;
|
|
373
|
+
build(p: Build | TableDefine, data: object, saved?: object | boolean): any;
|
|
374
|
+
dbType(): Promise<string>;
|
|
375
|
+
dbVersion(): Promise<string>;
|
|
376
|
+
query(...values: any[]): Promise<any[]>;
|
|
377
|
+
exec(...values: any[]): Promise<number>;
|
|
378
|
+
type(table: string): Promise<TableType | null>;
|
|
379
|
+
insert(table: IDBTable, data: object[], key: string[], conflictTarget?: string[] | boolean, conflictSet?: Record<string, SetValue> | boolean, conflictWhere?: WhereValue[]): PromiseLike<any[]>;
|
|
380
|
+
update(table: IDBTable, update: Record<string, SetValue>, where?: WhereValue[]): PromiseLike<number>;
|
|
381
|
+
updateReturn(returning: string[], table: IDBTable, update: Record<string, SetValue>, where?: WhereValue[]): PromiseLike<any[]>;
|
|
382
|
+
updateList(table: IDBTable, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<number>;
|
|
383
|
+
updateListReturn(returning: string[], table: IDBTable, update: Record<string, any>, primaryKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<any[]>;
|
|
384
|
+
count(table: IDBTable, where?: WhereValue[]): PromiseLike<number>;
|
|
385
|
+
select(select: SelectItem): PromiseLike<any[]>;
|
|
386
|
+
delete(table: IDBTable, where?: WhereValue[]): PromiseLike<number>;
|
|
387
|
+
deleteReturn(returning: string[], table: IDBTable, where?: WhereValue[]): PromiseLike<any[]>;
|
|
388
|
+
transaction<T>(fn: (signal: AbortSignal) => PromiseLike<T> | T): PromiseLike<T>;
|
|
389
|
+
abort(): boolean;
|
|
390
|
+
savepoint(): PromiseLike<Savepoint>;
|
|
646
391
|
}
|
|
647
|
-
interface
|
|
648
|
-
|
|
392
|
+
interface TableConnect {
|
|
393
|
+
(conn: ConnectionInterface, env: BaseEnvironment): ConnectionInterface;
|
|
649
394
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
/** 是否支持 sql 查询 */
|
|
654
|
-
sql?: boolean;
|
|
655
|
-
/** 是否支持数组类型 */
|
|
656
|
-
array?: boolean;
|
|
657
|
-
/** 是否支持对象存储 */
|
|
658
|
-
object?: boolean;
|
|
659
|
-
/** 是否支持递归查询 */
|
|
660
|
-
recursive?: boolean;
|
|
661
|
-
[key: string]: undefined | boolean;
|
|
395
|
+
interface Action<T> {
|
|
396
|
+
invoke(connect: () => Promise<ConnectionInterface>, connection: Connection, environment: BaseEnvironment): PromiseLike<T> | T;
|
|
397
|
+
connect?: TableConnect | null;
|
|
662
398
|
}
|
|
663
|
-
|
|
664
|
-
|
|
399
|
+
interface TableConnection<E extends object = object> {
|
|
400
|
+
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[]>;
|
|
401
|
+
update(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
402
|
+
updateReturn(environment: Environment<E>, returning: string[], table: string, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
403
|
+
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>;
|
|
404
|
+
updateManyReturn(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[], returning: string[]): PromiseLike<any[]>;
|
|
405
|
+
count(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
406
|
+
select(environment: Environment<E>, select: SelectItem[]): PromiseLike<any[]>;
|
|
407
|
+
delete(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
408
|
+
deleteReturn(environment: Environment<E>, returning: string[], table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
409
|
+
}
|
|
410
|
+
interface IConnection<E extends object = object> extends TableConnection<E> {
|
|
411
|
+
/** 数据库类型 */
|
|
412
|
+
readonly dbType: string;
|
|
413
|
+
/** 数据库版本 */
|
|
414
|
+
dbVersion(environment: Environment<E>): PromiseLike<string>;
|
|
415
|
+
exec(environment: Environment<E>, ...values: any): Promise<number>;
|
|
665
416
|
/**
|
|
666
|
-
*
|
|
667
|
-
* @
|
|
417
|
+
* 执行一条语句
|
|
418
|
+
* @param sql 要执行的 SQL 语句
|
|
668
419
|
*/
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
420
|
+
query(environment: Environment<E>, ...values: any): PromiseLike<any[]>;
|
|
421
|
+
type(environment: Environment<E>, table: string): PromiseLike<TableType | null>;
|
|
422
|
+
createSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
423
|
+
rollbackSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
424
|
+
releaseSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
425
|
+
createTable(environment: Environment<E>, table: string, columns: Column<any>[]): PromiseLike<number>;
|
|
426
|
+
dropTable(environment: Environment<E>, table: string): PromiseLike<number>;
|
|
427
|
+
renameTable(environment: Environment<E>, table: string, newName: string): PromiseLike<number>;
|
|
428
|
+
addColumn(environment: Environment<E>, table: string, column: string, type: string, options: ColumnOptions<any>): PromiseLike<number>;
|
|
429
|
+
changeColumn(environment: Environment<E>, table: string, column: string, type: string, options: ColumnOptions<any>): PromiseLike<number>;
|
|
430
|
+
changeColumnNull(environment: Environment<E>, table: string, column: string, nullable: boolean): PromiseLike<number>;
|
|
431
|
+
dropColumn(environment: Environment<E>, table: string, column: string): PromiseLike<number>;
|
|
432
|
+
renameColumn(environment: Environment<E>, table: string, column: string, newName: string): PromiseLike<number>;
|
|
433
|
+
addIndex(environment: Environment<E>, table: string, name: string, columns: string[], options: IndexOptions): PromiseLike<number>;
|
|
434
|
+
dropIndex(environment: Environment<E>, table: string, name: string): PromiseLike<number>;
|
|
435
|
+
loadTables(environment: Environment<E>, tables: string[]): PromiseLike<DBTable[]>;
|
|
436
|
+
syncTables(environment: Environment<E>, tables: DBTable[]): PromiseLike<void>;
|
|
437
|
+
transaction<R>(environment: Environment<E>, fn: (t: E) => R | PromiseLike<R>): PromiseLike<R>;
|
|
674
438
|
}
|
|
675
|
-
interface
|
|
676
|
-
|
|
677
|
-
|
|
439
|
+
interface Skip {
|
|
440
|
+
uncreatable?: boolean;
|
|
441
|
+
immutable?: boolean;
|
|
442
|
+
specific?: boolean;
|
|
443
|
+
where?: boolean;
|
|
678
444
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
declare function toNot(items?: WhereValue[] | null): WhereValue[] | null;
|
|
693
|
-
type WhereItem = {
|
|
694
|
-
exists?: false | null | undefined;
|
|
695
|
-
where?: null | undefined;
|
|
696
|
-
or?: null | undefined;
|
|
697
|
-
field: string | {
|
|
698
|
-
table?: string;
|
|
699
|
-
field: string;
|
|
700
|
-
} | (string | {
|
|
701
|
-
table?: string;
|
|
702
|
-
field: string;
|
|
703
|
-
})[];
|
|
704
|
-
value: any;
|
|
705
|
-
subquery?: SelectItem[] | null | undefined;
|
|
706
|
-
not?: boolean | undefined;
|
|
707
|
-
operator?: string | null | undefined;
|
|
708
|
-
};
|
|
709
|
-
type WhereExists = {
|
|
710
|
-
where?: null | undefined;
|
|
711
|
-
or?: null | undefined;
|
|
712
|
-
field?: null | undefined;
|
|
713
|
-
exists: true;
|
|
714
|
-
subquery: SelectItem[];
|
|
715
|
-
not?: boolean | undefined;
|
|
716
|
-
};
|
|
717
|
-
type WhereRaw = {
|
|
718
|
-
exists?: false | null | undefined;
|
|
719
|
-
field?: null | undefined;
|
|
720
|
-
or?: null | undefined;
|
|
721
|
-
where: readonly string[];
|
|
722
|
-
values: readonly any[];
|
|
723
|
-
not?: boolean | undefined;
|
|
724
|
-
};
|
|
725
|
-
type WhereOr = {
|
|
726
|
-
exists?: false | null | undefined;
|
|
727
|
-
where?: null | undefined;
|
|
728
|
-
field?: null | undefined;
|
|
729
|
-
or: WhereValue[][];
|
|
730
|
-
not?: boolean | undefined;
|
|
731
|
-
};
|
|
732
|
-
type WhereValue = WhereItem | WhereExists | WhereRaw | WhereOr;
|
|
733
|
-
type WhereLike = {
|
|
734
|
-
toWhereValue(): WhereValue[][];
|
|
735
|
-
};
|
|
736
|
-
type Wheres = WhereLike | Record<string, any> | (WhereLike | Record<string, any>)[];
|
|
737
|
-
declare class Where {
|
|
738
|
-
/**
|
|
739
|
-
* @overload
|
|
740
|
-
* @param {Wheres} matches
|
|
741
|
-
* @returns {WhereValue[]?}
|
|
742
|
-
*/
|
|
743
|
-
static parse(matches: Wheres): WhereValue[] | null;
|
|
744
|
-
/**
|
|
745
|
-
* @overload
|
|
746
|
-
* @param {string | string[]} field
|
|
747
|
-
* @param {any} value
|
|
748
|
-
* @returns {WhereValue[]?}
|
|
749
|
-
*/
|
|
750
|
-
static parse(field: string | string[], value: any): WhereValue[] | null;
|
|
751
|
-
/**
|
|
752
|
-
* @overload
|
|
753
|
-
* @param {string | string[]} field
|
|
754
|
-
* @param {string} operator
|
|
755
|
-
* @param {any} value
|
|
756
|
-
* @param {boolean} [not]
|
|
757
|
-
* @returns {WhereValue[]?}
|
|
758
|
-
*/
|
|
759
|
-
static parse(field: string | string[], operator: string, value: any, not?: boolean | undefined): WhereValue[] | null;
|
|
760
|
-
/**
|
|
761
|
-
* @overload
|
|
762
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
763
|
-
* @returns {WhereValue[]?}
|
|
764
|
-
*/
|
|
765
|
-
static parse(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): WhereValue[] | null;
|
|
766
|
-
/**
|
|
767
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
768
|
-
* @returns {WhereValue[]?}
|
|
769
|
-
*/
|
|
770
|
-
static parseParams(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): WhereValue[] | null;
|
|
771
|
-
/**
|
|
772
|
-
* @overload
|
|
773
|
-
* @param {Wheres} matches
|
|
774
|
-
* @returns {Where}
|
|
775
|
-
*/
|
|
776
|
-
static and(matches: Wheres): Where;
|
|
777
|
-
/**
|
|
778
|
-
*
|
|
779
|
-
* @overload
|
|
780
|
-
* @param {TemplateStringsArray} where
|
|
781
|
-
* @param {...any} values
|
|
782
|
-
* @returns {Where}
|
|
783
|
-
*/
|
|
784
|
-
static and(where: TemplateStringsArray, ...values: any[]): Where;
|
|
785
|
-
/**
|
|
786
|
-
* @overload
|
|
787
|
-
* @param {string} field
|
|
788
|
-
* @param {any} value
|
|
789
|
-
* @returns {Where}
|
|
790
|
-
*/
|
|
791
|
-
static and(field: string, value: any): Where;
|
|
792
|
-
/**
|
|
793
|
-
* @overload
|
|
794
|
-
* @param {string[]} field
|
|
795
|
-
* @param {any[]} value
|
|
796
|
-
* @returns {Where}
|
|
797
|
-
*/
|
|
798
|
-
static and(field: string[], value: any[]): Where;
|
|
799
|
-
/**
|
|
800
|
-
* @overload
|
|
801
|
-
* @param {string} field
|
|
802
|
-
* @param {string} operator
|
|
803
|
-
* @param {any} value
|
|
804
|
-
* @param {boolean} [not]
|
|
805
|
-
* @returns {Where}
|
|
806
|
-
*/
|
|
807
|
-
static and(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
808
|
-
/**
|
|
809
|
-
* @overload
|
|
810
|
-
* @param {string[]} field
|
|
811
|
-
* @param {string} operator
|
|
812
|
-
* @param {any[]} value
|
|
813
|
-
* @param {boolean} [not]
|
|
814
|
-
* @returns {Where}
|
|
815
|
-
*/
|
|
816
|
-
static and(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
817
|
-
/**
|
|
818
|
-
* @overload
|
|
819
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
820
|
-
* @returns {Where}
|
|
821
|
-
*/
|
|
822
|
-
static and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
823
|
-
/**
|
|
824
|
-
* @overload
|
|
825
|
-
* @param {Wheres} matches
|
|
826
|
-
* @returns {Where}
|
|
827
|
-
*/
|
|
828
|
-
static where(matches: Wheres): Where;
|
|
829
|
-
/**
|
|
830
|
-
*
|
|
831
|
-
* @overload
|
|
832
|
-
* @param {TemplateStringsArray} where
|
|
833
|
-
* @param {...any} values
|
|
834
|
-
* @returns {Where}
|
|
835
|
-
*/
|
|
836
|
-
static where(where: TemplateStringsArray, ...values: any[]): Where;
|
|
837
|
-
/**
|
|
838
|
-
* @overload
|
|
839
|
-
* @param {string} field
|
|
840
|
-
* @param {any} value
|
|
841
|
-
* @returns {Where}
|
|
842
|
-
*/
|
|
843
|
-
static where(field: string, value: any): Where;
|
|
844
|
-
/**
|
|
845
|
-
* @overload
|
|
846
|
-
* @param {string[]} field
|
|
847
|
-
* @param {any[]} value
|
|
848
|
-
* @returns {Where}
|
|
849
|
-
*/
|
|
850
|
-
static where(field: string[], value: any[]): Where;
|
|
851
|
-
/**
|
|
852
|
-
* @overload
|
|
853
|
-
* @param {string} field
|
|
854
|
-
* @param {string} operator
|
|
855
|
-
* @param {any} value
|
|
856
|
-
* @param {boolean} [not]
|
|
857
|
-
* @returns {Where}
|
|
858
|
-
*/
|
|
859
|
-
static where(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
860
|
-
/**
|
|
861
|
-
* @overload
|
|
862
|
-
* @param {string[]} field
|
|
863
|
-
* @param {string} operator
|
|
864
|
-
* @param {any[]} value
|
|
865
|
-
* @param {boolean} [not]
|
|
866
|
-
* @returns {Where}
|
|
867
|
-
*/
|
|
868
|
-
static where(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
869
|
-
/**
|
|
870
|
-
* @overload
|
|
871
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
872
|
-
* @returns {Where}
|
|
873
|
-
*/
|
|
874
|
-
static where(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
875
|
-
/**
|
|
876
|
-
* @overload
|
|
877
|
-
* @param {Wheres} matches
|
|
878
|
-
* @returns {Where}
|
|
879
|
-
*/
|
|
880
|
-
static or(matches: Wheres): Where;
|
|
881
|
-
/**
|
|
882
|
-
*
|
|
883
|
-
* @overload
|
|
884
|
-
* @param {TemplateStringsArray} where
|
|
885
|
-
* @param {...any} values
|
|
886
|
-
* @returns {Where}
|
|
887
|
-
*/
|
|
888
|
-
static or(where: TemplateStringsArray, ...values: any[]): Where;
|
|
889
|
-
/**
|
|
890
|
-
* @overload
|
|
891
|
-
* @param {string} field
|
|
892
|
-
* @param {any} value
|
|
893
|
-
* @returns {Where}
|
|
894
|
-
*/
|
|
895
|
-
static or(field: string, value: any): Where;
|
|
896
|
-
/**
|
|
897
|
-
* @overload
|
|
898
|
-
* @param {string[]} field
|
|
899
|
-
* @param {any[]} value
|
|
900
|
-
* @returns {Where}
|
|
901
|
-
*/
|
|
902
|
-
static or(field: string[], value: any[]): Where;
|
|
903
|
-
/**
|
|
904
|
-
* @overload
|
|
905
|
-
* @param {string} field
|
|
906
|
-
* @param {string} operator
|
|
907
|
-
* @param {any} value
|
|
908
|
-
* @param {boolean} [not]
|
|
909
|
-
* @returns {Where}
|
|
910
|
-
*/
|
|
911
|
-
static or(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
912
|
-
/**
|
|
913
|
-
* @overload
|
|
914
|
-
* @param {string[]} field
|
|
915
|
-
* @param {string} operator
|
|
916
|
-
* @param {any[]} value
|
|
917
|
-
* @param {boolean} [not]
|
|
918
|
-
* @returns {Where}
|
|
919
|
-
*/
|
|
920
|
-
static or(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
921
|
-
/**
|
|
922
|
-
* @overload
|
|
923
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
924
|
-
* @returns {Where}
|
|
925
|
-
*/
|
|
926
|
-
static or(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
927
|
-
/**
|
|
928
|
-
* @overload
|
|
929
|
-
* @param {Wheres} matches
|
|
930
|
-
* @returns {Where}
|
|
931
|
-
*/
|
|
932
|
-
static not(matches: Wheres): Where;
|
|
933
|
-
/**
|
|
934
|
-
*
|
|
935
|
-
* @overload
|
|
936
|
-
* @param {TemplateStringsArray} where
|
|
937
|
-
* @param {...any} values
|
|
938
|
-
* @returns {Where}
|
|
939
|
-
*/
|
|
940
|
-
static not(where: TemplateStringsArray, ...values: any[]): Where;
|
|
941
|
-
/**
|
|
942
|
-
* @overload
|
|
943
|
-
* @param {string} field
|
|
944
|
-
* @param {any} value
|
|
945
|
-
* @returns {Where}
|
|
946
|
-
*/
|
|
947
|
-
static not(field: string, value: any): Where;
|
|
948
|
-
/**
|
|
949
|
-
* @overload
|
|
950
|
-
* @param {string[]} field
|
|
951
|
-
* @param {any[]} value
|
|
952
|
-
* @returns {Where}
|
|
953
|
-
*/
|
|
954
|
-
static not(field: string[], value: any[]): Where;
|
|
955
|
-
/**
|
|
956
|
-
* @overload
|
|
957
|
-
* @param {string} field
|
|
958
|
-
* @param {string} operator
|
|
959
|
-
* @param {any} value
|
|
960
|
-
* @param {boolean} [not]
|
|
961
|
-
* @returns {Where}
|
|
962
|
-
*/
|
|
963
|
-
static not(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
964
|
-
/**
|
|
965
|
-
* @overload
|
|
966
|
-
* @param {string[]} field
|
|
967
|
-
* @param {string} operator
|
|
968
|
-
* @param {any[]} value
|
|
969
|
-
* @param {boolean} [not]
|
|
970
|
-
* @returns {Where}
|
|
971
|
-
*/
|
|
972
|
-
static not(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
973
|
-
/**
|
|
974
|
-
* @overload
|
|
975
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
976
|
-
* @returns {Where}
|
|
977
|
-
*/
|
|
978
|
-
static not(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
979
|
-
/**
|
|
980
|
-
* @overload
|
|
981
|
-
* @param {Wheres} matches
|
|
982
|
-
* @returns {Where}
|
|
983
|
-
*/
|
|
984
|
-
static orNot(matches: Wheres): Where;
|
|
985
|
-
/**
|
|
986
|
-
*
|
|
987
|
-
* @overload
|
|
988
|
-
* @param {TemplateStringsArray} where
|
|
989
|
-
* @param {...any} values
|
|
990
|
-
* @returns {Where}
|
|
991
|
-
*/
|
|
992
|
-
static orNot(where: TemplateStringsArray, ...values: any[]): Where;
|
|
993
|
-
/**
|
|
994
|
-
* @overload
|
|
995
|
-
* @param {string} field
|
|
996
|
-
* @param {any} value
|
|
997
|
-
* @returns {Where}
|
|
998
|
-
*/
|
|
999
|
-
static orNot(field: string, value: any): Where;
|
|
1000
|
-
/**
|
|
1001
|
-
* @overload
|
|
1002
|
-
* @param {string[]} field
|
|
1003
|
-
* @param {any[]} value
|
|
1004
|
-
* @returns {Where}
|
|
1005
|
-
*/
|
|
1006
|
-
static orNot(field: string[], value: any[]): Where;
|
|
1007
|
-
/**
|
|
1008
|
-
* @overload
|
|
1009
|
-
* @param {string} field
|
|
1010
|
-
* @param {string} operator
|
|
1011
|
-
* @param {any} value
|
|
1012
|
-
* @param {boolean} [not]
|
|
1013
|
-
* @returns {Where}
|
|
1014
|
-
*/
|
|
1015
|
-
static orNot(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1016
|
-
/**
|
|
1017
|
-
* @overload
|
|
1018
|
-
* @param {string[]} field
|
|
1019
|
-
* @param {string} operator
|
|
1020
|
-
* @param {any[]} value
|
|
1021
|
-
* @param {boolean} [not]
|
|
1022
|
-
* @returns {Where}
|
|
1023
|
-
*/
|
|
1024
|
-
static orNot(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1025
|
-
/**
|
|
1026
|
-
* @overload
|
|
1027
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1028
|
-
* @returns {Where}
|
|
1029
|
-
*/
|
|
1030
|
-
static orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1031
|
-
/**
|
|
1032
|
-
*
|
|
1033
|
-
* @param {...SelectItem} subquery
|
|
1034
|
-
* @returns {Where}
|
|
1035
|
-
*/
|
|
1036
|
-
static exists(...subquery: SelectItem[]): Where;
|
|
1037
|
-
/**
|
|
1038
|
-
*
|
|
1039
|
-
* @param {...SelectItem} subquery
|
|
1040
|
-
* @returns {Where}
|
|
1041
|
-
*/
|
|
1042
|
-
static notExists(...subquery: SelectItem[]): Where;
|
|
1043
|
-
toWhereValue(): WhereValue[][];
|
|
1044
|
-
/**
|
|
1045
|
-
* @overload
|
|
1046
|
-
* @param {Wheres} matches
|
|
1047
|
-
* @returns {this}
|
|
1048
|
-
*/
|
|
1049
|
-
and(matches: Wheres): this;
|
|
1050
|
-
/**
|
|
1051
|
-
*
|
|
1052
|
-
* @overload
|
|
1053
|
-
* @param {TemplateStringsArray} where
|
|
1054
|
-
* @param {...any} values
|
|
1055
|
-
* @returns {this}
|
|
1056
|
-
*/
|
|
1057
|
-
and(where: TemplateStringsArray, ...values: any[]): this;
|
|
1058
|
-
/**
|
|
1059
|
-
* @overload
|
|
1060
|
-
* @param {string} field
|
|
1061
|
-
* @param {any} value
|
|
1062
|
-
* @returns {this}
|
|
1063
|
-
*/
|
|
1064
|
-
and(field: string, value: any): this;
|
|
1065
|
-
/**
|
|
1066
|
-
* @overload
|
|
1067
|
-
* @param {string[]} field
|
|
1068
|
-
* @param {any[]} value
|
|
1069
|
-
* @returns {this}
|
|
1070
|
-
*/
|
|
1071
|
-
and(field: string[], value: any[]): this;
|
|
1072
|
-
/**
|
|
1073
|
-
* @overload
|
|
1074
|
-
* @param {string} field
|
|
1075
|
-
* @param {string} operator
|
|
1076
|
-
* @param {any} value
|
|
1077
|
-
* @param {boolean} [not]
|
|
1078
|
-
* @returns {this}
|
|
1079
|
-
*/
|
|
1080
|
-
and(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1081
|
-
/**
|
|
1082
|
-
* @overload
|
|
1083
|
-
* @param {string[]} field
|
|
1084
|
-
* @param {string} operator
|
|
1085
|
-
* @param {any[]} value
|
|
1086
|
-
* @param {boolean} [not]
|
|
1087
|
-
* @returns {this}
|
|
1088
|
-
*/
|
|
1089
|
-
and(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1090
|
-
/**
|
|
1091
|
-
* @overload
|
|
1092
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1093
|
-
* @returns {this}
|
|
1094
|
-
*/
|
|
1095
|
-
and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1096
|
-
/**
|
|
1097
|
-
* @overload
|
|
1098
|
-
* @param {Wheres} matches
|
|
1099
|
-
* @returns {this}
|
|
1100
|
-
*/
|
|
1101
|
-
or(matches: Wheres): this;
|
|
1102
|
-
/**
|
|
1103
|
-
*
|
|
1104
|
-
* @overload
|
|
1105
|
-
* @param {TemplateStringsArray} where
|
|
1106
|
-
* @param {...any} values
|
|
1107
|
-
* @returns {this}
|
|
1108
|
-
*/
|
|
1109
|
-
or(where: TemplateStringsArray, ...values: any[]): this;
|
|
1110
|
-
/**
|
|
1111
|
-
* @overload
|
|
1112
|
-
* @param {string} field
|
|
1113
|
-
* @param {any} value
|
|
1114
|
-
* @returns {this}
|
|
1115
|
-
*/
|
|
1116
|
-
or(field: string, value: any): this;
|
|
1117
|
-
/**
|
|
1118
|
-
* @overload
|
|
1119
|
-
* @param {string[]} field
|
|
1120
|
-
* @param {any[]} value
|
|
1121
|
-
* @returns {this}
|
|
1122
|
-
*/
|
|
1123
|
-
or(field: string[], value: any[]): this;
|
|
1124
|
-
/**
|
|
1125
|
-
* @overload
|
|
1126
|
-
* @param {string} field
|
|
1127
|
-
* @param {string} operator
|
|
1128
|
-
* @param {any} value
|
|
1129
|
-
* @param {boolean} [not]
|
|
1130
|
-
* @returns {this}
|
|
1131
|
-
*/
|
|
1132
|
-
or(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1133
|
-
/**
|
|
1134
|
-
* @overload
|
|
1135
|
-
* @param {string[]} field
|
|
1136
|
-
* @param {string} operator
|
|
1137
|
-
* @param {any[]} value
|
|
1138
|
-
* @param {boolean} [not]
|
|
1139
|
-
* @returns {this}
|
|
1140
|
-
*/
|
|
1141
|
-
or(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1142
|
-
/**
|
|
1143
|
-
* @overload
|
|
1144
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1145
|
-
* @returns {this}
|
|
1146
|
-
*/
|
|
1147
|
-
or(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1148
|
-
/**
|
|
1149
|
-
* @overload
|
|
1150
|
-
* @param {Wheres} matches
|
|
1151
|
-
* @returns {this}
|
|
1152
|
-
*/
|
|
1153
|
-
not(matches: Wheres): this;
|
|
1154
|
-
/**
|
|
1155
|
-
*
|
|
1156
|
-
* @overload
|
|
1157
|
-
* @param {TemplateStringsArray} where
|
|
1158
|
-
* @param {...any} values
|
|
1159
|
-
* @returns {this}
|
|
1160
|
-
*/
|
|
1161
|
-
not(where: TemplateStringsArray, ...values: any[]): this;
|
|
1162
|
-
/**
|
|
1163
|
-
* @overload
|
|
1164
|
-
* @param {string} field
|
|
1165
|
-
* @param {any} value
|
|
1166
|
-
* @returns {this}
|
|
1167
|
-
*/
|
|
1168
|
-
not(field: string, value: any): this;
|
|
1169
|
-
/**
|
|
1170
|
-
* @overload
|
|
1171
|
-
* @param {string[]} field
|
|
1172
|
-
* @param {any[]} value
|
|
1173
|
-
* @returns {this}
|
|
1174
|
-
*/
|
|
1175
|
-
not(field: string[], value: any[]): this;
|
|
1176
|
-
/**
|
|
1177
|
-
* @overload
|
|
1178
|
-
* @param {string} field
|
|
1179
|
-
* @param {string} operator
|
|
1180
|
-
* @param {any} value
|
|
1181
|
-
* @param {boolean} [not]
|
|
1182
|
-
* @returns {this}
|
|
1183
|
-
*/
|
|
1184
|
-
not(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1185
|
-
/**
|
|
1186
|
-
* @overload
|
|
1187
|
-
* @param {string[]} field
|
|
1188
|
-
* @param {string} operator
|
|
1189
|
-
* @param {any[]} value
|
|
1190
|
-
* @param {boolean} [not]
|
|
1191
|
-
* @returns {this}
|
|
1192
|
-
*/
|
|
1193
|
-
not(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1194
|
-
/**
|
|
1195
|
-
* @overload
|
|
1196
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1197
|
-
* @returns {this}
|
|
1198
|
-
*/
|
|
1199
|
-
not(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1200
|
-
/**
|
|
1201
|
-
* @overload
|
|
1202
|
-
* @param {Wheres} matches
|
|
1203
|
-
* @returns {this}
|
|
1204
|
-
*/
|
|
1205
|
-
orNot(matches: Wheres): this;
|
|
1206
|
-
/**
|
|
1207
|
-
*
|
|
1208
|
-
* @overload
|
|
1209
|
-
* @param {TemplateStringsArray} where
|
|
1210
|
-
* @param {...any} values
|
|
1211
|
-
* @returns {this}
|
|
1212
|
-
*/
|
|
1213
|
-
orNot(where: TemplateStringsArray, ...values: any[]): this;
|
|
1214
|
-
/**
|
|
1215
|
-
* @overload
|
|
1216
|
-
* @param {string} field
|
|
1217
|
-
* @param {any} value
|
|
1218
|
-
* @returns {this}
|
|
1219
|
-
*/
|
|
1220
|
-
orNot(field: string, value: any): this;
|
|
1221
|
-
/**
|
|
1222
|
-
* @overload
|
|
1223
|
-
* @param {string[]} field
|
|
1224
|
-
* @param {any[]} value
|
|
1225
|
-
* @returns {this}
|
|
1226
|
-
*/
|
|
1227
|
-
orNot(field: string[], value: any[]): this;
|
|
1228
|
-
/**
|
|
1229
|
-
* @overload
|
|
1230
|
-
* @param {string} field
|
|
1231
|
-
* @param {string} operator
|
|
1232
|
-
* @param {any} value
|
|
1233
|
-
* @param {boolean} [not]
|
|
1234
|
-
* @returns {this}
|
|
1235
|
-
*/
|
|
1236
|
-
orNot(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1237
|
-
/**
|
|
1238
|
-
* @overload
|
|
1239
|
-
* @param {string[]} field
|
|
1240
|
-
* @param {string} operator
|
|
1241
|
-
* @param {any[]} value
|
|
1242
|
-
* @param {boolean} [not]
|
|
1243
|
-
* @returns {this}
|
|
1244
|
-
*/
|
|
1245
|
-
orNot(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1246
|
-
/**
|
|
1247
|
-
* @overload
|
|
1248
|
-
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1249
|
-
* @returns {this}
|
|
1250
|
-
*/
|
|
1251
|
-
orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1252
|
-
/**
|
|
1253
|
-
*
|
|
1254
|
-
* @param {...SelectItem} subquery
|
|
1255
|
-
* @returns {this}
|
|
1256
|
-
*/
|
|
1257
|
-
exists(...subquery: SelectItem[]): this;
|
|
1258
|
-
/**
|
|
1259
|
-
*
|
|
1260
|
-
* @param {...SelectItem} subquery
|
|
1261
|
-
* @returns {this}
|
|
1262
|
-
*/
|
|
1263
|
-
notExists(...subquery: SelectItem[]): this;
|
|
1264
|
-
#private;
|
|
445
|
+
interface TransactionFn {
|
|
446
|
+
<T>(fn: (t: Connection) => PromiseLike<T> | T): Promise<T>;
|
|
447
|
+
}
|
|
448
|
+
type TransactionHandlerArray = [
|
|
449
|
+
promise: TransactionHandler['promise'],
|
|
450
|
+
commit: TransactionHandler['commit'],
|
|
451
|
+
rollback: TransactionHandler['rollback']
|
|
452
|
+
];
|
|
453
|
+
interface TransactionHandler extends TransactionHandlerArray {
|
|
454
|
+
promise: Promise<void>;
|
|
455
|
+
commit(): Promise<void>;
|
|
456
|
+
rollback(e?: any): Promise<void>;
|
|
457
|
+
[Symbol.dispose](): void;
|
|
1265
458
|
}
|
|
1266
459
|
|
|
1267
460
|
/** 字段基本类型 */
|
|
@@ -1358,853 +551,1258 @@ interface FieldTypeDefine<T extends MainFieldType = MainFieldType, A extends boo
|
|
|
1358
551
|
type: T;
|
|
1359
552
|
/** 是否可为空 */
|
|
1360
553
|
nullable: N;
|
|
1361
|
-
/** 是否为数组 */
|
|
554
|
+
/** 是否为数组 */
|
|
555
|
+
array: A;
|
|
556
|
+
}
|
|
557
|
+
type ToType<T extends MainFieldType = MainFieldType, A extends boolean = boolean, N extends boolean = boolean> = N extends false ? A extends false ? ToFieldType<T> : A extends true ? ToFieldType<T>[] : ToFieldType<T> | ToFieldType<T>[] : A extends false ? ToFieldType<T> | null : A extends true ? ToFieldType<T>[] | null : ToFieldType<T> | ToFieldType<T>[] | null;
|
|
558
|
+
type FieldDefineType<F extends FieldTypeDefine> = F extends FieldTypeDefine<infer T, infer A, infer N> ? ToType<T, A, N> : never;
|
|
559
|
+
type Fields<T extends MainFieldType = MainFieldType> = Record<string, FieldDefine<T>>;
|
|
560
|
+
type FieldValue<T extends Fields> = {
|
|
561
|
+
[K in keyof T]: FieldDefineType<T[K]>;
|
|
562
|
+
};
|
|
563
|
+
interface IndexOptions {
|
|
564
|
+
unique?: boolean;
|
|
565
|
+
name?: string;
|
|
566
|
+
includes?: string[];
|
|
567
|
+
}
|
|
568
|
+
interface IndexInfo extends IndexOptions {
|
|
569
|
+
fields: string[];
|
|
570
|
+
}
|
|
571
|
+
interface Index extends IndexInfo {
|
|
572
|
+
name: string;
|
|
573
|
+
}
|
|
574
|
+
interface Hooks<T extends Record<string, any> = Record<string, any>> {
|
|
575
|
+
where(this: unknown, conn: Connection, model: TableDefine): PromiseLike<void | Where> | void;
|
|
576
|
+
beforeCreateMany(this: unknown, conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void | Record<string, any>[]> | void | Record<string, any>[];
|
|
577
|
+
afterCreateMany(this: unknown, conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void> | void;
|
|
578
|
+
beforeCreate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
579
|
+
afterCreate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void> | void;
|
|
580
|
+
beforeUpdate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>, set: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
581
|
+
afterUpdate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>, oldRecord: Record<string, any>): PromiseLike<void> | void;
|
|
582
|
+
beforeDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
583
|
+
afterDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
584
|
+
}
|
|
585
|
+
interface TableDefine<T extends Fields = Fields, TT extends string | undefined = string | undefined> {
|
|
586
|
+
readonly connect?: TableConnect | null;
|
|
587
|
+
/** 字段信息 */
|
|
588
|
+
readonly fields: T;
|
|
589
|
+
/** 表名 */
|
|
590
|
+
readonly table: TT;
|
|
591
|
+
/** 是否启用软删除 */
|
|
592
|
+
readonly pseudo?: string;
|
|
593
|
+
/** 索引信息 */
|
|
594
|
+
readonly indexes?: readonly IndexInfo[];
|
|
595
|
+
/** 钩子 */
|
|
596
|
+
readonly hooks?: Partial<Hooks>;
|
|
597
|
+
}
|
|
598
|
+
type TableValue<T extends TableDefine> = T extends TableDefine<infer F> ? FieldValue<F> : never;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* @template {keyof FieldType} T
|
|
602
|
+
* @overload
|
|
603
|
+
* @param {T} type
|
|
604
|
+
* @param {{
|
|
605
|
+
* nullable?: false;
|
|
606
|
+
* array?: false;
|
|
607
|
+
* default?: ToType<T, false, false> | symbol;
|
|
608
|
+
* [k: string]: any;
|
|
609
|
+
* } & FieldDefineOption} [options]
|
|
610
|
+
* @returns {FieldDecorator<ToType<T, false, false>>}
|
|
611
|
+
*/
|
|
612
|
+
declare function field$1<T extends keyof FieldType>(type: T, options?: ({
|
|
613
|
+
[k: string]: any;
|
|
614
|
+
nullable?: false;
|
|
615
|
+
array?: false;
|
|
616
|
+
default?: ToType<T, false, false> | symbol;
|
|
617
|
+
} & FieldDefineOption) | undefined): FieldDecorator<ToType<T, false, false>>;
|
|
618
|
+
/**
|
|
619
|
+
* @template {keyof FieldType} T
|
|
620
|
+
* @overload
|
|
621
|
+
* @param {T} type
|
|
622
|
+
* @param {{
|
|
623
|
+
* nullable?: false;
|
|
624
|
+
* array: true;
|
|
625
|
+
* default?: ToType<T, true, false> | symbol;
|
|
626
|
+
* [k: string]: any;
|
|
627
|
+
* } & FieldDefineOption} options
|
|
628
|
+
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
629
|
+
*/
|
|
630
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
631
|
+
nullable?: false;
|
|
632
|
+
array: true;
|
|
633
|
+
default?: ToType<T, true, false> | symbol;
|
|
634
|
+
[k: string]: any;
|
|
635
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
636
|
+
/**
|
|
637
|
+
* @template {keyof FieldType} T
|
|
638
|
+
* @overload
|
|
639
|
+
* @param {T} type
|
|
640
|
+
* @param {true} array
|
|
641
|
+
* @param {{
|
|
642
|
+
* nullable?: false;
|
|
643
|
+
* default?: ToType<T, true, false> | symbol;
|
|
644
|
+
* [k: string]: any;
|
|
645
|
+
* } & FieldDefineOption} options
|
|
646
|
+
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
647
|
+
*/
|
|
648
|
+
declare function field$1<T extends keyof FieldType>(type: T, array: true, options: {
|
|
649
|
+
nullable?: false;
|
|
650
|
+
default?: ToType<T, true, false> | symbol;
|
|
651
|
+
[k: string]: any;
|
|
652
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
653
|
+
/**
|
|
654
|
+
* @template {keyof FieldType} T
|
|
655
|
+
* @overload
|
|
656
|
+
* @param {T} type
|
|
657
|
+
* @param {{
|
|
658
|
+
* nullable: true;
|
|
659
|
+
* array?: false;
|
|
660
|
+
* default?: ToType<T, false, true> | symbol;
|
|
661
|
+
* [k: string]: any;
|
|
662
|
+
* } & FieldDefineOption} options
|
|
663
|
+
* @returns {FieldDecorator<ToType<T, false, true>>}
|
|
664
|
+
*/
|
|
665
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
666
|
+
nullable: true;
|
|
667
|
+
array?: false;
|
|
668
|
+
default?: ToType<T, false, true> | symbol;
|
|
669
|
+
[k: string]: any;
|
|
670
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, false, true>>;
|
|
671
|
+
/**
|
|
672
|
+
* @template {keyof FieldType} T
|
|
673
|
+
* @overload
|
|
674
|
+
* @param {T} type
|
|
675
|
+
* @param {{
|
|
676
|
+
* nullable: true;
|
|
677
|
+
* array: true;
|
|
678
|
+
* default?: ToType<T, true, true> | symbol;
|
|
679
|
+
* [k: string]: any;
|
|
680
|
+
* } & FieldDefineOption} options
|
|
681
|
+
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
682
|
+
*/
|
|
683
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
684
|
+
nullable: true;
|
|
685
|
+
array: true;
|
|
686
|
+
default?: ToType<T, true, true> | symbol;
|
|
687
|
+
[k: string]: any;
|
|
688
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, true>>;
|
|
689
|
+
/**
|
|
690
|
+
* @template {keyof FieldType} T
|
|
691
|
+
* @overload
|
|
692
|
+
* @param {T} type
|
|
693
|
+
* @param {true} array
|
|
694
|
+
* @param {{
|
|
695
|
+
* nullable: true;
|
|
696
|
+
* default?: ToType<T, true, true> | symbol;
|
|
697
|
+
* [k: string]: any;
|
|
698
|
+
* } & FieldDefineOption} options
|
|
699
|
+
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
700
|
+
*/
|
|
701
|
+
declare function field$1<T extends keyof FieldType>(type: T, array: true, options: {
|
|
702
|
+
nullable: true;
|
|
703
|
+
default?: ToType<T, true, true> | symbol;
|
|
704
|
+
[k: string]: any;
|
|
705
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, true>>;
|
|
706
|
+
/**
|
|
707
|
+
* @template {keyof FieldType} T
|
|
708
|
+
* @template {boolean} A
|
|
709
|
+
* @overload
|
|
710
|
+
* @param {T} type
|
|
711
|
+
* @param {{
|
|
712
|
+
* nullable: true;
|
|
713
|
+
* array: A;
|
|
714
|
+
* default?: ToType<T, A, true> | symbol;
|
|
715
|
+
* [k: string]: any;
|
|
716
|
+
* } & FieldDefineOption} options
|
|
717
|
+
* @returns {FieldDecorator<ToType<T, A, true>>}
|
|
718
|
+
*/
|
|
719
|
+
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
720
|
+
nullable: true;
|
|
721
|
+
array: A;
|
|
722
|
+
default?: ToType<T, A, true> | symbol;
|
|
723
|
+
[k: string]: any;
|
|
724
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, A, true>>;
|
|
725
|
+
/**
|
|
726
|
+
* @template {keyof FieldType} T
|
|
727
|
+
* @template {boolean} A
|
|
728
|
+
* @overload
|
|
729
|
+
* @param {T} type
|
|
730
|
+
* @param {{
|
|
731
|
+
* nullable?: false;
|
|
732
|
+
* array: A;
|
|
733
|
+
* default?: ToType<T, A, false> | symbol;
|
|
734
|
+
* [k: string]: any;
|
|
735
|
+
* } & FieldDefineOption} options
|
|
736
|
+
* @returns {FieldDecorator<ToType<T, A, false>>}
|
|
737
|
+
*/
|
|
738
|
+
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
739
|
+
nullable?: false;
|
|
740
|
+
array: A;
|
|
741
|
+
default?: ToType<T, A, false> | symbol;
|
|
742
|
+
[k: string]: any;
|
|
743
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, A, false>>;
|
|
744
|
+
/**
|
|
745
|
+
* @template {keyof FieldType} T
|
|
746
|
+
* @template {boolean} N
|
|
747
|
+
* @overload
|
|
748
|
+
* @param {T} type
|
|
749
|
+
* @param {{
|
|
750
|
+
* nullable: N;
|
|
751
|
+
* array?: false;
|
|
752
|
+
* default?: ToType<T, false, N> | symbol;
|
|
753
|
+
* [k: string]: any;
|
|
754
|
+
* } & FieldDefineOption} options
|
|
755
|
+
* @returns {FieldDecorator<ToType<T, false, N>>}
|
|
756
|
+
*/
|
|
757
|
+
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
758
|
+
nullable: N;
|
|
759
|
+
array?: false;
|
|
760
|
+
default?: ToType<T, false, N> | symbol;
|
|
761
|
+
[k: string]: any;
|
|
762
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, false, N>>;
|
|
763
|
+
/**
|
|
764
|
+
* @template {keyof FieldType} T
|
|
765
|
+
* @template {boolean} N
|
|
766
|
+
* @overload
|
|
767
|
+
* @param {T} type
|
|
768
|
+
* @param {{
|
|
769
|
+
* nullable: N;
|
|
770
|
+
* array: true;
|
|
771
|
+
* default?: ToType<T, true, N> | symbol;
|
|
772
|
+
* [k: string]: any;
|
|
773
|
+
* } & FieldDefineOption} options
|
|
774
|
+
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
775
|
+
*/
|
|
776
|
+
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
777
|
+
nullable: N;
|
|
778
|
+
array: true;
|
|
779
|
+
default?: ToType<T, true, N> | symbol;
|
|
780
|
+
[k: string]: any;
|
|
781
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
782
|
+
/**
|
|
783
|
+
* @template {keyof FieldType} T
|
|
784
|
+
* @template {boolean} N
|
|
785
|
+
* @overload
|
|
786
|
+
* @param {T} type
|
|
787
|
+
* @param {true} array
|
|
788
|
+
* @param {{
|
|
789
|
+
* nullable: N;
|
|
790
|
+
* default?: ToType<T, true, N> | symbol;
|
|
791
|
+
* [k: string]: any;
|
|
792
|
+
* } & FieldDefineOption} options
|
|
793
|
+
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
794
|
+
*/
|
|
795
|
+
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, array: true, options: {
|
|
796
|
+
nullable: N;
|
|
797
|
+
default?: ToType<T, true, N> | symbol;
|
|
798
|
+
[k: string]: any;
|
|
799
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
800
|
+
/**
|
|
801
|
+
* @template {keyof FieldType} T
|
|
802
|
+
* @template {boolean} A
|
|
803
|
+
* @template {boolean} N
|
|
804
|
+
* @overload
|
|
805
|
+
* @param {T} type
|
|
806
|
+
* @param {{
|
|
807
|
+
* nullable: N;
|
|
808
|
+
* array: A;
|
|
809
|
+
* default?: ToType<T, A, N> | symbol;
|
|
810
|
+
* [k: string]: any;
|
|
811
|
+
* } & FieldDefineOption} options
|
|
812
|
+
* @returns {FieldDecorator<ToType<T, A, N>>}
|
|
813
|
+
*/
|
|
814
|
+
declare function field$1<T extends keyof FieldType, A extends boolean, N extends boolean>(type: T, options: {
|
|
815
|
+
nullable: N;
|
|
1362
816
|
array: A;
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
afterCreateMany(this: unknown, conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void> | void;
|
|
1385
|
-
beforeCreate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
1386
|
-
afterCreate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void> | void;
|
|
1387
|
-
beforeUpdate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>, set: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
1388
|
-
afterUpdate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>, oldRecord: Record<string, any>): PromiseLike<void> | void;
|
|
1389
|
-
beforeDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
1390
|
-
afterDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
1391
|
-
}
|
|
1392
|
-
interface TableDefine<T extends Fields = Fields, TT extends string | undefined = string | undefined> {
|
|
1393
|
-
readonly connect?: TableConnect | null;
|
|
1394
|
-
/** 字段信息 */
|
|
1395
|
-
readonly fields: T;
|
|
1396
|
-
/** 表名 */
|
|
1397
|
-
readonly table: TT;
|
|
1398
|
-
/** 是否启用软删除 */
|
|
1399
|
-
readonly pseudo?: string;
|
|
1400
|
-
/** 索引信息 */
|
|
1401
|
-
readonly indexes?: readonly IndexInfo[];
|
|
1402
|
-
/** 钩子 */
|
|
1403
|
-
readonly hooks?: Partial<Hooks>;
|
|
1404
|
-
}
|
|
1405
|
-
type TableValue<T extends TableDefine> = T extends TableDefine<infer F> ? FieldValue<F> : never;
|
|
817
|
+
default?: ToType<T, A, N> | symbol;
|
|
818
|
+
[k: string]: any;
|
|
819
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, A, N>>;
|
|
820
|
+
/**
|
|
821
|
+
* @template {keyof FieldType} T
|
|
822
|
+
* @overload
|
|
823
|
+
* @param {T} type
|
|
824
|
+
* @param {{
|
|
825
|
+
* nullable?: boolean;
|
|
826
|
+
* array?: boolean;
|
|
827
|
+
* default?: ToType<T, boolean, boolean> | symbol;
|
|
828
|
+
* [k: string]: any;
|
|
829
|
+
* } & FieldDefineOption} options
|
|
830
|
+
* @returns {FieldDecorator<ToType<T, boolean, boolean>>}
|
|
831
|
+
*/
|
|
832
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
833
|
+
nullable?: boolean;
|
|
834
|
+
array?: boolean;
|
|
835
|
+
default?: ToType<T, boolean, boolean> | symbol;
|
|
836
|
+
[k: string]: any;
|
|
837
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, boolean, boolean>>;
|
|
1406
838
|
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
839
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
840
|
+
/**
|
|
841
|
+
* @param {string} prop
|
|
842
|
+
* @param {any} value
|
|
843
|
+
* @param {boolean} [array]
|
|
844
|
+
* @param {boolean} [end]
|
|
845
|
+
* @returns {FieldDecorator<any>}
|
|
846
|
+
*/
|
|
847
|
+
declare function prop(prop: string, value: any, array?: boolean, end?: boolean): FieldDecorator<any>;
|
|
848
|
+
|
|
849
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
850
|
+
/**
|
|
851
|
+
*
|
|
852
|
+
* @param {string} [column]
|
|
853
|
+
* @returns {FieldDecorator<any>}
|
|
854
|
+
*/
|
|
855
|
+
declare function column(column?: string): FieldDecorator<any>;
|
|
856
|
+
|
|
857
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
858
|
+
/**
|
|
859
|
+
*
|
|
860
|
+
* @param {number} [primary]
|
|
861
|
+
* @returns {FieldDecorator<any>}
|
|
862
|
+
*/
|
|
863
|
+
declare function primary(primary?: number): FieldDecorator<any>;
|
|
864
|
+
|
|
865
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
866
|
+
/** @returns {FieldDecorator<any>} */
|
|
867
|
+
declare function uncreatable(): FieldDecorator<any>;
|
|
868
|
+
|
|
869
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
870
|
+
/** @returns {FieldDecorator<any>} */
|
|
871
|
+
declare function immutable(): FieldDecorator<any>;
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* 索引信息
|
|
875
|
+
* @overload
|
|
876
|
+
* @param {string[]} fields
|
|
877
|
+
* @param {IndexOptions} [options]
|
|
878
|
+
* @returns {ClassDecorator}
|
|
879
|
+
*/
|
|
880
|
+
declare function index(fields: string[], options?: IndexOptions | undefined): ClassDecorator;
|
|
881
|
+
/**
|
|
882
|
+
* 索引信息
|
|
883
|
+
* @overload
|
|
884
|
+
* @param {string} [name]
|
|
885
|
+
* @param {boolean} [unique]
|
|
886
|
+
* @returns {FieldDecorator<any>}
|
|
887
|
+
*/
|
|
888
|
+
declare function index(name?: string | undefined, unique?: boolean | undefined): FieldDecorator<any>;
|
|
889
|
+
/**
|
|
890
|
+
* 索引信息
|
|
891
|
+
* @overload
|
|
892
|
+
* @param {boolean} [unique]
|
|
893
|
+
* @returns {FieldDecorator<any>}
|
|
894
|
+
*/
|
|
895
|
+
declare function index(unique?: boolean | undefined): FieldDecorator<any>;
|
|
896
|
+
|
|
897
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
898
|
+
/**
|
|
899
|
+
* 默认排序顺序,绝对值表示在排序列表中的顺序,负数表示逆序排序, 0 表示不排序
|
|
900
|
+
* @param {number} sort
|
|
901
|
+
* @returns {FieldDecorator<any>}
|
|
902
|
+
*/
|
|
903
|
+
declare function sort(sort: number): FieldDecorator<any>;
|
|
904
|
+
|
|
905
|
+
/** @import { ClassDecorator } from './index.mjs' */
|
|
906
|
+
/**
|
|
907
|
+
*
|
|
908
|
+
* @param {string} pseudo
|
|
909
|
+
* @returns {ClassDecorator}
|
|
910
|
+
*/
|
|
911
|
+
declare function pseudo(pseudo: string): ClassDecorator;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* @template T
|
|
915
|
+
* @overload
|
|
916
|
+
* @param {now} value
|
|
917
|
+
* @returns {FieldDecorator<string | Date>}
|
|
918
|
+
*/
|
|
919
|
+
declare function defaultValue<T>(value: typeof now): FieldDecorator<string | Date>;
|
|
920
|
+
/**
|
|
921
|
+
* @template T
|
|
922
|
+
* @overload
|
|
923
|
+
* @param {uuid} value
|
|
924
|
+
* @returns {FieldDecorator<string>}
|
|
925
|
+
*/
|
|
926
|
+
declare function defaultValue<T>(value: typeof uuid): FieldDecorator<string>;
|
|
927
|
+
/**
|
|
928
|
+
* @template T
|
|
929
|
+
* @overload
|
|
930
|
+
* @param {T} value
|
|
931
|
+
* @returns {FieldDecorator<T>}
|
|
932
|
+
*/
|
|
933
|
+
declare function defaultValue<T>(value: T): FieldDecorator<T>;
|
|
1414
934
|
|
|
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
935
|
/**
|
|
1422
|
-
*
|
|
1423
|
-
* @
|
|
936
|
+
*
|
|
937
|
+
* @overload
|
|
938
|
+
* @param {string} table
|
|
939
|
+
* @returns {ClassDecorator}
|
|
1424
940
|
*/
|
|
1425
|
-
declare function
|
|
941
|
+
declare function model(table: string): ClassDecorator;
|
|
1426
942
|
/**
|
|
1427
|
-
* @
|
|
1428
|
-
* @
|
|
943
|
+
* @template {Record<string, any>} T
|
|
944
|
+
* @overload
|
|
945
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
946
|
+
* @param {Record<string, Constraint>} constraints
|
|
947
|
+
* @param {true} array
|
|
948
|
+
* @param {FieldDefineOption} [options]
|
|
949
|
+
* @returns {FieldDecorator<T[]>}
|
|
1429
950
|
*/
|
|
1430
|
-
declare function
|
|
951
|
+
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
952
|
+
new (...a: any): T;
|
|
953
|
+
}, constraints: Record<string, Constraint>, array: true, options?: FieldDefineOption | undefined): FieldDecorator<T[]>;
|
|
1431
954
|
/**
|
|
1432
|
-
* @
|
|
1433
|
-
* @
|
|
955
|
+
* @template {Record<string, any>} T
|
|
956
|
+
* @overload
|
|
957
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
958
|
+
* @param {Record<string, Constraint>} constraints
|
|
959
|
+
* @param {false} [array]
|
|
960
|
+
* @param {FieldDefineOption} [options]
|
|
961
|
+
* @returns {FieldDecorator<T>}
|
|
1434
962
|
*/
|
|
1435
|
-
declare function
|
|
963
|
+
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
964
|
+
new (...a: any): T;
|
|
965
|
+
}, constraints: Record<string, Constraint>, array?: false | undefined, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
1436
966
|
/**
|
|
1437
|
-
* @
|
|
1438
|
-
* @
|
|
967
|
+
* @template {Record<string, any>} T
|
|
968
|
+
* @overload
|
|
969
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
970
|
+
* @param {Record<string, Constraint>} constraints
|
|
971
|
+
* @param {FieldDefineOption} [options]
|
|
972
|
+
* @returns {FieldDecorator<T>}
|
|
1439
973
|
*/
|
|
1440
|
-
declare function
|
|
974
|
+
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
975
|
+
new (...a: any): T;
|
|
976
|
+
}, constraints: Record<string, Constraint>, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
1441
977
|
/**
|
|
1442
|
-
* @
|
|
1443
|
-
* @
|
|
978
|
+
* @template {Record<string, any>} T
|
|
979
|
+
* @template {boolean} [A=boolean]
|
|
980
|
+
* @overload
|
|
981
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
982
|
+
* @param {Record<string, Constraint>} constraints
|
|
983
|
+
* @param {A} array
|
|
984
|
+
* @param {FieldDefineOption} [options]
|
|
985
|
+
* @returns {FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>}
|
|
1444
986
|
*/
|
|
1445
|
-
declare function
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
}
|
|
987
|
+
declare function model<T extends Record<string, any>, A extends boolean = boolean>(type: TableDefine & {
|
|
988
|
+
new (...a: any): T;
|
|
989
|
+
}, constraints: Record<string, Constraint>, array: A, options?: FieldDefineOption | undefined): FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>;
|
|
990
|
+
/**
|
|
991
|
+
* @template {object} T
|
|
992
|
+
* @overload
|
|
993
|
+
* @param {TableDefine} type
|
|
994
|
+
* @param {Record<string, Constraint>} constraints
|
|
995
|
+
* @param {true} array
|
|
996
|
+
* @param {FieldDefineOption} [options]
|
|
997
|
+
* @returns {FieldDecorator<T[]>}
|
|
998
|
+
*/
|
|
999
|
+
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, array: true, options?: FieldDefineOption | undefined): FieldDecorator<T[]>;
|
|
1000
|
+
/**
|
|
1001
|
+
* @template {object} T
|
|
1002
|
+
* @overload
|
|
1003
|
+
* @param {TableDefine} type
|
|
1004
|
+
* @param {Record<string, Constraint>} constraints
|
|
1005
|
+
* @param {false} [array]
|
|
1006
|
+
* @param {FieldDefineOption} [options]
|
|
1007
|
+
* @returns {FieldDecorator<T>}
|
|
1008
|
+
*/
|
|
1009
|
+
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, array?: false | undefined, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
1010
|
+
/**
|
|
1011
|
+
* @template {object} T
|
|
1012
|
+
* @overload
|
|
1013
|
+
* @param {TableDefine} type
|
|
1014
|
+
* @param {Record<string, Constraint>} constraints
|
|
1015
|
+
* @param {FieldDefineOption} [options]
|
|
1016
|
+
* @returns {FieldDecorator<T>}
|
|
1017
|
+
*/
|
|
1018
|
+
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
1019
|
+
/**
|
|
1020
|
+
* @template {object} T
|
|
1021
|
+
* @template {boolean} [A=boolean]
|
|
1022
|
+
* @overload
|
|
1023
|
+
* @param {TableDefine} type
|
|
1024
|
+
* @param {Record<string, Constraint>} constraints
|
|
1025
|
+
* @param {A} array
|
|
1026
|
+
* @param {FieldDefineOption} [options]
|
|
1027
|
+
* @returns {FieldDecorator<A extends false ? T :A extends true ? T[] : T | T[]>}
|
|
1028
|
+
*/
|
|
1029
|
+
declare function model<T extends Record<string, any>, A extends boolean = boolean>(type: TableDefine, constraints: Record<string, Constraint>, array: A, options?: FieldDefineOption | undefined): FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>;
|
|
1464
1030
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
};
|
|
1481
|
-
}
|
|
1482
|
-
interface Options {
|
|
1483
|
-
distinct?: boolean;
|
|
1484
|
-
range?: FindRange;
|
|
1485
|
-
select?: Record<string, Select> | null;
|
|
1486
|
-
/** 排序配置,true 表示逆序 */
|
|
1487
|
-
sort?: [field: string, desc: boolean][];
|
|
1488
|
-
/** 匹配信息 */
|
|
1489
|
-
where: WhereValue[];
|
|
1490
|
-
/** 偏移量 */
|
|
1491
|
-
offset?: number;
|
|
1492
|
-
/** 最大返回数 */
|
|
1493
|
-
limit?: number;
|
|
1494
|
-
update?: Record<string, SetValue>;
|
|
1495
|
-
alias?: string;
|
|
1496
|
-
group?: string[];
|
|
1497
|
-
lock?: 'S' | 'X' | null;
|
|
1498
|
-
}
|
|
1499
|
-
interface Queryable<T extends Fields = Fields> extends TableDefine<T> {
|
|
1500
|
-
readonly options: Options;
|
|
1501
|
-
}
|
|
1031
|
+
/**
|
|
1032
|
+
* @param {number} [size]
|
|
1033
|
+
* @returns {FieldDecorator<Date?>}
|
|
1034
|
+
*/
|
|
1035
|
+
declare function creating(size?: number): FieldDecorator<Date | null>;
|
|
1036
|
+
/**
|
|
1037
|
+
* @param {number} [size]
|
|
1038
|
+
* @returns {FieldDecorator<Date?>}
|
|
1039
|
+
*/
|
|
1040
|
+
declare function updating(size?: number): FieldDecorator<Date | null>;
|
|
1041
|
+
/**
|
|
1042
|
+
* @param {number} [size]
|
|
1043
|
+
* @returns {FieldDecorator<Date?>}
|
|
1044
|
+
*/
|
|
1045
|
+
declare function deleting(size?: number): FieldDecorator<Date | null>;
|
|
1502
1046
|
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
type
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
nullable?: boolean;
|
|
1047
|
+
/**
|
|
1048
|
+
* @overload
|
|
1049
|
+
* @param {Partial<Hooks>} hook
|
|
1050
|
+
* @param {boolean} [approach] 插入位置是否为更靠近执行的位置
|
|
1051
|
+
* @returns {ClassDecorator}
|
|
1052
|
+
*/
|
|
1053
|
+
declare function hooks(hook: Partial<Hooks>, approach?: boolean | undefined): ClassDecorator;
|
|
1054
|
+
/**
|
|
1055
|
+
* @overload
|
|
1056
|
+
* @param {Function} Model
|
|
1057
|
+
* @param {Partial<Hooks>} hook
|
|
1058
|
+
* @param {boolean} [approach] 插入位置是否为更靠近执行的位置
|
|
1059
|
+
* @returns {void}
|
|
1060
|
+
*/
|
|
1061
|
+
declare function hooks(Model: Function, hook: Partial<Hooks>, approach?: boolean | undefined): void;
|
|
1062
|
+
/** @type {Hook<Hooks['where']>} */
|
|
1063
|
+
declare const where: Hook<Hooks["where"]>;
|
|
1064
|
+
/** @type {Hook<Hooks['beforeCreateMany']>} */
|
|
1065
|
+
declare const beforeCreateMany: Hook<Hooks["beforeCreateMany"]>;
|
|
1066
|
+
/** @type {Hook<Hooks['afterCreateMany']>} */
|
|
1067
|
+
declare const afterCreateMany: Hook<Hooks["afterCreateMany"]>;
|
|
1068
|
+
/** @type {Hook<Hooks['beforeCreate']>} */
|
|
1069
|
+
declare const beforeCreate: Hook<Hooks["beforeCreate"]>;
|
|
1070
|
+
/** @type {Hook<Hooks['afterCreate']>} */
|
|
1071
|
+
declare const afterCreate: Hook<Hooks["afterCreate"]>;
|
|
1072
|
+
/** @type {Hook<Hooks['beforeUpdate']>} */
|
|
1073
|
+
declare const beforeUpdate: Hook<Hooks["beforeUpdate"]>;
|
|
1074
|
+
/** @type {Hook<Hooks['afterUpdate']>} */
|
|
1075
|
+
declare const afterUpdate: Hook<Hooks["afterUpdate"]>;
|
|
1076
|
+
/** @type {Hook<Hooks['beforeDelete']>} */
|
|
1077
|
+
declare const beforeDelete: Hook<Hooks["beforeDelete"]>;
|
|
1078
|
+
/** @type {Hook<Hooks['afterDelete']>} */
|
|
1079
|
+
declare const afterDelete: Hook<Hooks["afterDelete"]>;
|
|
1080
|
+
|
|
1081
|
+
type ClassDecorator = (val: Function, ctx: ClassDecoratorContext) => any;
|
|
1082
|
+
type FieldDecorator<T> = (val: {
|
|
1083
|
+
get(): T;
|
|
1084
|
+
set(v: T): void;
|
|
1085
|
+
}, ctx: ClassAccessorDecoratorContext) => any;
|
|
1086
|
+
type MethodDecorator<T extends Function> = (val: T, ctx: ClassMethodDecoratorContext<any, T>) => any;
|
|
1087
|
+
|
|
1088
|
+
/** 特性支持情况 */
|
|
1089
|
+
interface Support {
|
|
1090
|
+
/** 是否支持 sql 查询 */
|
|
1091
|
+
sql?: boolean;
|
|
1092
|
+
/** 是否支持数组类型 */
|
|
1550
1093
|
array?: boolean;
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
unique?: boolean;
|
|
1557
|
-
name?: string;
|
|
1558
|
-
}
|
|
1559
|
-
interface DBTable {
|
|
1560
|
-
table: string;
|
|
1561
|
-
fields: Record<string, DBColumn>;
|
|
1562
|
-
indexes?: DBIndex[];
|
|
1563
|
-
primary?: string;
|
|
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;
|
|
1094
|
+
/** 是否支持对象存储 */
|
|
1095
|
+
object?: boolean;
|
|
1096
|
+
/** 是否支持递归查询 */
|
|
1097
|
+
recursive?: boolean;
|
|
1098
|
+
[key: string]: undefined | boolean;
|
|
1591
1099
|
}
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
select(environment: Environment<E>, select: SelectItem[]): PromiseLike<any[]>;
|
|
1600
|
-
delete(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
1601
|
-
deleteReturn(environment: Environment<E>, returning: string[], table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
1100
|
+
|
|
1101
|
+
type MaybePromise<T> = PromiseLike<T> | T;
|
|
1102
|
+
|
|
1103
|
+
interface Hook<T extends Hooks[keyof Hooks]> {
|
|
1104
|
+
(approach?: boolean): MethodDecorator<T>;
|
|
1105
|
+
(hook: T, approach?: boolean): ClassDecorator;
|
|
1106
|
+
(Model: Function, hook: T, approach?: boolean): void;
|
|
1602
1107
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* @param {WhereValue[]?} [items]
|
|
1111
|
+
* @returns {WhereValue[]?}
|
|
1112
|
+
*/
|
|
1113
|
+
declare function toNot(items?: WhereValue[] | null): WhereValue[] | null;
|
|
1114
|
+
type WhereItem = {
|
|
1115
|
+
exists?: false | null | undefined;
|
|
1116
|
+
where?: null | undefined;
|
|
1117
|
+
or?: null | undefined;
|
|
1118
|
+
field: string | {
|
|
1119
|
+
table?: string;
|
|
1120
|
+
field: string;
|
|
1121
|
+
} | (string | {
|
|
1122
|
+
table?: string;
|
|
1123
|
+
field: string;
|
|
1124
|
+
})[];
|
|
1125
|
+
value: any;
|
|
1126
|
+
subquery?: SelectItem[] | null | undefined;
|
|
1127
|
+
not?: boolean | undefined;
|
|
1128
|
+
operator?: string | null | undefined;
|
|
1129
|
+
};
|
|
1130
|
+
type WhereExists = {
|
|
1131
|
+
where?: null | undefined;
|
|
1132
|
+
or?: null | undefined;
|
|
1133
|
+
field?: null | undefined;
|
|
1134
|
+
exists: true;
|
|
1135
|
+
subquery: SelectItem[];
|
|
1136
|
+
not?: boolean | undefined;
|
|
1137
|
+
};
|
|
1138
|
+
type WhereRaw = {
|
|
1139
|
+
exists?: false | null | undefined;
|
|
1140
|
+
field?: null | undefined;
|
|
1141
|
+
or?: null | undefined;
|
|
1142
|
+
where: readonly string[];
|
|
1143
|
+
values: readonly any[];
|
|
1144
|
+
not?: boolean | undefined;
|
|
1145
|
+
};
|
|
1146
|
+
type WhereOr = {
|
|
1147
|
+
exists?: false | null | undefined;
|
|
1148
|
+
where?: null | undefined;
|
|
1149
|
+
field?: null | undefined;
|
|
1150
|
+
or: WhereValue[][];
|
|
1151
|
+
not?: boolean | undefined;
|
|
1152
|
+
};
|
|
1153
|
+
type WhereValue = WhereItem | WhereExists | WhereRaw | WhereOr;
|
|
1154
|
+
type WhereLike = {
|
|
1155
|
+
toWhereValue(): WhereValue[][];
|
|
1156
|
+
};
|
|
1157
|
+
type Wheres = WhereLike | Record<string, any> | (WhereLike | Record<string, any>)[];
|
|
1158
|
+
declare class Where {
|
|
1159
|
+
/**
|
|
1160
|
+
* @overload
|
|
1161
|
+
* @param {Wheres} matches
|
|
1162
|
+
* @returns {WhereValue[]?}
|
|
1163
|
+
*/
|
|
1164
|
+
static parse(matches: Wheres): WhereValue[] | null;
|
|
1165
|
+
/**
|
|
1166
|
+
* @overload
|
|
1167
|
+
* @param {string | string[]} field
|
|
1168
|
+
* @param {any} value
|
|
1169
|
+
* @returns {WhereValue[]?}
|
|
1170
|
+
*/
|
|
1171
|
+
static parse(field: string | string[], value: any): WhereValue[] | null;
|
|
1172
|
+
/**
|
|
1173
|
+
* @overload
|
|
1174
|
+
* @param {string | string[]} field
|
|
1175
|
+
* @param {string} operator
|
|
1176
|
+
* @param {any} value
|
|
1177
|
+
* @param {boolean} [not]
|
|
1178
|
+
* @returns {WhereValue[]?}
|
|
1179
|
+
*/
|
|
1180
|
+
static parse(field: string | string[], operator: string, value: any, not?: boolean | undefined): WhereValue[] | null;
|
|
1181
|
+
/**
|
|
1182
|
+
* @overload
|
|
1183
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1184
|
+
* @returns {WhereValue[]?}
|
|
1185
|
+
*/
|
|
1186
|
+
static parse(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): WhereValue[] | null;
|
|
1187
|
+
/**
|
|
1188
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1189
|
+
* @returns {WhereValue[]?}
|
|
1190
|
+
*/
|
|
1191
|
+
static parseParams(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): WhereValue[] | null;
|
|
1192
|
+
/**
|
|
1193
|
+
* @overload
|
|
1194
|
+
* @param {Wheres} matches
|
|
1195
|
+
* @returns {Where}
|
|
1196
|
+
*/
|
|
1197
|
+
static and(matches: Wheres): Where;
|
|
1198
|
+
/**
|
|
1199
|
+
*
|
|
1200
|
+
* @overload
|
|
1201
|
+
* @param {TemplateStringsArray} where
|
|
1202
|
+
* @param {...any} values
|
|
1203
|
+
* @returns {Where}
|
|
1204
|
+
*/
|
|
1205
|
+
static and(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1206
|
+
/**
|
|
1207
|
+
* @overload
|
|
1208
|
+
* @param {string} field
|
|
1209
|
+
* @param {any} value
|
|
1210
|
+
* @returns {Where}
|
|
1211
|
+
*/
|
|
1212
|
+
static and(field: string, value: any): Where;
|
|
1213
|
+
/**
|
|
1214
|
+
* @overload
|
|
1215
|
+
* @param {string[]} field
|
|
1216
|
+
* @param {any[]} value
|
|
1217
|
+
* @returns {Where}
|
|
1218
|
+
*/
|
|
1219
|
+
static and(field: string[], value: any[]): Where;
|
|
1220
|
+
/**
|
|
1221
|
+
* @overload
|
|
1222
|
+
* @param {string} field
|
|
1223
|
+
* @param {string} operator
|
|
1224
|
+
* @param {any} value
|
|
1225
|
+
* @param {boolean} [not]
|
|
1226
|
+
* @returns {Where}
|
|
1227
|
+
*/
|
|
1228
|
+
static and(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1229
|
+
/**
|
|
1230
|
+
* @overload
|
|
1231
|
+
* @param {string[]} field
|
|
1232
|
+
* @param {string} operator
|
|
1233
|
+
* @param {any[]} value
|
|
1234
|
+
* @param {boolean} [not]
|
|
1235
|
+
* @returns {Where}
|
|
1236
|
+
*/
|
|
1237
|
+
static and(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1238
|
+
/**
|
|
1239
|
+
* @overload
|
|
1240
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1241
|
+
* @returns {Where}
|
|
1242
|
+
*/
|
|
1243
|
+
static and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1244
|
+
/**
|
|
1245
|
+
* @overload
|
|
1246
|
+
* @param {Wheres} matches
|
|
1247
|
+
* @returns {Where}
|
|
1248
|
+
*/
|
|
1249
|
+
static where(matches: Wheres): Where;
|
|
1250
|
+
/**
|
|
1251
|
+
*
|
|
1252
|
+
* @overload
|
|
1253
|
+
* @param {TemplateStringsArray} where
|
|
1254
|
+
* @param {...any} values
|
|
1255
|
+
* @returns {Where}
|
|
1256
|
+
*/
|
|
1257
|
+
static where(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1258
|
+
/**
|
|
1259
|
+
* @overload
|
|
1260
|
+
* @param {string} field
|
|
1261
|
+
* @param {any} value
|
|
1262
|
+
* @returns {Where}
|
|
1263
|
+
*/
|
|
1264
|
+
static where(field: string, value: any): Where;
|
|
1265
|
+
/**
|
|
1266
|
+
* @overload
|
|
1267
|
+
* @param {string[]} field
|
|
1268
|
+
* @param {any[]} value
|
|
1269
|
+
* @returns {Where}
|
|
1270
|
+
*/
|
|
1271
|
+
static where(field: string[], value: any[]): Where;
|
|
1609
1272
|
/**
|
|
1610
|
-
*
|
|
1611
|
-
* @param
|
|
1273
|
+
* @overload
|
|
1274
|
+
* @param {string} field
|
|
1275
|
+
* @param {string} operator
|
|
1276
|
+
* @param {any} value
|
|
1277
|
+
* @param {boolean} [not]
|
|
1278
|
+
* @returns {Where}
|
|
1612
1279
|
*/
|
|
1613
|
-
|
|
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>;
|
|
1618
|
-
createTable(environment: Environment<E>, table: string, columns: Column<any>[]): PromiseLike<number>;
|
|
1619
|
-
dropTable(environment: Environment<E>, table: string): PromiseLike<number>;
|
|
1620
|
-
renameTable(environment: Environment<E>, table: string, newName: string): PromiseLike<number>;
|
|
1621
|
-
addColumn(environment: Environment<E>, table: string, column: string, type: string, options: ColumnOptions<any>): PromiseLike<number>;
|
|
1622
|
-
changeColumn(environment: Environment<E>, table: string, column: string, type: string, options: ColumnOptions<any>): PromiseLike<number>;
|
|
1623
|
-
changeColumnNull(environment: Environment<E>, table: string, column: string, nullable: boolean): PromiseLike<number>;
|
|
1624
|
-
dropColumn(environment: Environment<E>, table: string, column: string): PromiseLike<number>;
|
|
1625
|
-
renameColumn(environment: Environment<E>, table: string, column: string, newName: string): PromiseLike<number>;
|
|
1626
|
-
addIndex(environment: Environment<E>, table: string, name: string, columns: string[], options: IndexOptions): PromiseLike<number>;
|
|
1627
|
-
dropIndex(environment: Environment<E>, table: string, name: string): PromiseLike<number>;
|
|
1628
|
-
loadTables(environment: Environment<E>, tables: string[]): PromiseLike<DBTable[]>;
|
|
1629
|
-
syncTables(environment: Environment<E>, tables: DBTable[]): PromiseLike<void>;
|
|
1630
|
-
transaction<R>(environment: Environment<E>, fn: (t: E) => R | PromiseLike<R>): PromiseLike<R>;
|
|
1631
|
-
}
|
|
1632
|
-
interface Skip {
|
|
1633
|
-
uncreatable?: boolean;
|
|
1634
|
-
immutable?: boolean;
|
|
1635
|
-
specific?: boolean;
|
|
1636
|
-
where?: boolean;
|
|
1637
|
-
}
|
|
1638
|
-
interface TransactionFn {
|
|
1639
|
-
<T>(fn: (t: Connection) => PromiseLike<T> | T): Promise<T>;
|
|
1640
|
-
}
|
|
1641
|
-
type TransactionHandlerArray = [
|
|
1642
|
-
promise: TransactionHandler['promise'],
|
|
1643
|
-
commit: TransactionHandler['commit'],
|
|
1644
|
-
rollback: TransactionHandler['rollback']
|
|
1645
|
-
];
|
|
1646
|
-
interface TransactionHandler extends TransactionHandlerArray {
|
|
1647
|
-
promise: Promise<void>;
|
|
1648
|
-
commit(): Promise<void>;
|
|
1649
|
-
rollback(e?: any): Promise<void>;
|
|
1650
|
-
[Symbol.dispose](): void;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
declare const Destroy: unique symbol;
|
|
1654
|
-
interface Destroy {
|
|
1655
|
-
[Destroy](connection: Connection, run: (data: any) => Promise<object | null>, table: TableDefine<Fields<MainFieldType>>): PromiseLike<this | null>;
|
|
1656
|
-
}
|
|
1657
|
-
declare const PseudoDestroy: unique symbol;
|
|
1658
|
-
interface PseudoDestroy {
|
|
1659
|
-
[PseudoDestroy](connection: Connection, update: Record<string, SetValue>, run: (data: any) => Promise<object | null>, table: TableDefine<Fields<MainFieldType>>): PromiseLike<this | null>;
|
|
1660
|
-
}
|
|
1661
|
-
declare const Save: unique symbol;
|
|
1662
|
-
interface Save {
|
|
1663
|
-
[Save](connection: Connection, run: (data: any, newData?: any) => Promise<object | null>, newData: Record<string, any> | null, table: TableDefine): PromiseLike<this | null>;
|
|
1664
|
-
}
|
|
1665
|
-
declare const Create: unique symbol;
|
|
1666
|
-
interface Create<T = unknown> {
|
|
1667
|
-
[Create](connection: Connection, data: object, run: (data: any, that: any) => Promise<object>, table: TableDefine): PromiseLike<T>;
|
|
1668
|
-
}
|
|
1669
|
-
declare const Build: unique symbol;
|
|
1670
|
-
interface Build<T = unknown> {
|
|
1671
|
-
[Build](data: object, others: object | boolean): T;
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
/**
|
|
1675
|
-
* @template {{}} [E={}]
|
|
1676
|
-
*/
|
|
1677
|
-
declare class Connection<E extends {} = {}> {
|
|
1280
|
+
static where(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1678
1281
|
/**
|
|
1679
|
-
*
|
|
1680
|
-
* @param {
|
|
1681
|
-
* @param {
|
|
1282
|
+
* @overload
|
|
1283
|
+
* @param {string[]} field
|
|
1284
|
+
* @param {string} operator
|
|
1285
|
+
* @param {any[]} value
|
|
1286
|
+
* @param {boolean} [not]
|
|
1287
|
+
* @returns {Where}
|
|
1682
1288
|
*/
|
|
1683
|
-
|
|
1289
|
+
static where(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1684
1290
|
/**
|
|
1685
|
-
*
|
|
1686
|
-
* @
|
|
1291
|
+
* @overload
|
|
1292
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1293
|
+
* @returns {Where}
|
|
1687
1294
|
*/
|
|
1688
|
-
|
|
1295
|
+
static where(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1689
1296
|
/**
|
|
1690
|
-
* @
|
|
1691
|
-
* @param {
|
|
1692
|
-
* @returns {
|
|
1297
|
+
* @overload
|
|
1298
|
+
* @param {Wheres} matches
|
|
1299
|
+
* @returns {Where}
|
|
1693
1300
|
*/
|
|
1694
|
-
|
|
1695
|
-
/** @return {Promise<string>} */
|
|
1696
|
-
dbType(): Promise<string>;
|
|
1697
|
-
/** @return {Promise<string>} */
|
|
1698
|
-
dbVersion(): Promise<string>;
|
|
1301
|
+
static or(matches: Wheres): Where;
|
|
1699
1302
|
/**
|
|
1700
1303
|
*
|
|
1701
|
-
* @
|
|
1702
|
-
* @
|
|
1304
|
+
* @overload
|
|
1305
|
+
* @param {TemplateStringsArray} where
|
|
1306
|
+
* @param {...any} values
|
|
1307
|
+
* @returns {Where}
|
|
1703
1308
|
*/
|
|
1704
|
-
|
|
1309
|
+
static or(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1705
1310
|
/**
|
|
1706
|
-
*
|
|
1707
|
-
* @param {
|
|
1708
|
-
* @
|
|
1311
|
+
* @overload
|
|
1312
|
+
* @param {string} field
|
|
1313
|
+
* @param {any} value
|
|
1314
|
+
* @returns {Where}
|
|
1709
1315
|
*/
|
|
1710
|
-
|
|
1316
|
+
static or(field: string, value: any): Where;
|
|
1317
|
+
/**
|
|
1318
|
+
* @overload
|
|
1319
|
+
* @param {string[]} field
|
|
1320
|
+
* @param {any[]} value
|
|
1321
|
+
* @returns {Where}
|
|
1322
|
+
*/
|
|
1323
|
+
static or(field: string[], value: any[]): Where;
|
|
1324
|
+
/**
|
|
1325
|
+
* @overload
|
|
1326
|
+
* @param {string} field
|
|
1327
|
+
* @param {string} operator
|
|
1328
|
+
* @param {any} value
|
|
1329
|
+
* @param {boolean} [not]
|
|
1330
|
+
* @returns {Where}
|
|
1331
|
+
*/
|
|
1332
|
+
static or(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1333
|
+
/**
|
|
1334
|
+
* @overload
|
|
1335
|
+
* @param {string[]} field
|
|
1336
|
+
* @param {string} operator
|
|
1337
|
+
* @param {any[]} value
|
|
1338
|
+
* @param {boolean} [not]
|
|
1339
|
+
* @returns {Where}
|
|
1340
|
+
*/
|
|
1341
|
+
static or(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1342
|
+
/**
|
|
1343
|
+
* @overload
|
|
1344
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1345
|
+
* @returns {Where}
|
|
1346
|
+
*/
|
|
1347
|
+
static or(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1348
|
+
/**
|
|
1349
|
+
* @overload
|
|
1350
|
+
* @param {Wheres} matches
|
|
1351
|
+
* @returns {Where}
|
|
1352
|
+
*/
|
|
1353
|
+
static not(matches: Wheres): Where;
|
|
1711
1354
|
/**
|
|
1712
1355
|
*
|
|
1713
|
-
* @
|
|
1714
|
-
* @
|
|
1356
|
+
* @overload
|
|
1357
|
+
* @param {TemplateStringsArray} where
|
|
1358
|
+
* @param {...any} values
|
|
1359
|
+
* @returns {Where}
|
|
1715
1360
|
*/
|
|
1716
|
-
|
|
1361
|
+
static not(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1717
1362
|
/**
|
|
1718
|
-
* @template T
|
|
1719
1363
|
* @overload
|
|
1720
|
-
* @param {
|
|
1721
|
-
* @param {
|
|
1722
|
-
* @
|
|
1723
|
-
* @returns {T}
|
|
1364
|
+
* @param {string} field
|
|
1365
|
+
* @param {any} value
|
|
1366
|
+
* @returns {Where}
|
|
1724
1367
|
*/
|
|
1725
|
-
|
|
1368
|
+
static not(field: string, value: any): Where;
|
|
1726
1369
|
/**
|
|
1727
|
-
* @template {Fields} T
|
|
1728
1370
|
* @overload
|
|
1729
|
-
* @param {
|
|
1730
|
-
* @param {
|
|
1731
|
-
* @
|
|
1732
|
-
* @returns {FieldValue<T>}
|
|
1371
|
+
* @param {string[]} field
|
|
1372
|
+
* @param {any[]} value
|
|
1373
|
+
* @returns {Where}
|
|
1733
1374
|
*/
|
|
1734
|
-
|
|
1375
|
+
static not(field: string[], value: any[]): Where;
|
|
1735
1376
|
/**
|
|
1736
|
-
* @deprecated
|
|
1737
|
-
* @template {TableDefine} T
|
|
1738
1377
|
* @overload
|
|
1739
|
-
* @param {
|
|
1740
|
-
* @param {
|
|
1741
|
-
* @
|
|
1378
|
+
* @param {string} field
|
|
1379
|
+
* @param {string} operator
|
|
1380
|
+
* @param {any} value
|
|
1381
|
+
* @param {boolean} [not]
|
|
1382
|
+
* @returns {Where}
|
|
1742
1383
|
*/
|
|
1743
|
-
|
|
1384
|
+
static not(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1744
1385
|
/**
|
|
1745
|
-
* @deprecated
|
|
1746
|
-
* @template {TableDefine} T
|
|
1747
1386
|
* @overload
|
|
1748
|
-
* @param {
|
|
1749
|
-
* @param {
|
|
1750
|
-
* @
|
|
1387
|
+
* @param {string[]} field
|
|
1388
|
+
* @param {string} operator
|
|
1389
|
+
* @param {any[]} value
|
|
1390
|
+
* @param {boolean} [not]
|
|
1391
|
+
* @returns {Where}
|
|
1751
1392
|
*/
|
|
1752
|
-
|
|
1393
|
+
static not(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1394
|
+
/**
|
|
1395
|
+
* @overload
|
|
1396
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1397
|
+
* @returns {Where}
|
|
1398
|
+
*/
|
|
1399
|
+
static not(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1753
1400
|
/**
|
|
1754
|
-
* @deprecated
|
|
1755
|
-
* @template {TableDefine} T
|
|
1756
1401
|
* @overload
|
|
1757
|
-
* @param {
|
|
1758
|
-
* @
|
|
1759
|
-
* @returns {Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>}
|
|
1402
|
+
* @param {Wheres} matches
|
|
1403
|
+
* @returns {Where}
|
|
1760
1404
|
*/
|
|
1761
|
-
|
|
1405
|
+
static orNot(matches: Wheres): Where;
|
|
1762
1406
|
/**
|
|
1763
1407
|
*
|
|
1764
|
-
* @
|
|
1765
|
-
* @
|
|
1766
|
-
* @param
|
|
1767
|
-
* @
|
|
1768
|
-
* @param {Skip} [skip]
|
|
1769
|
-
* @returns {Promise<T extends TableDefine<infer F> ? FieldValue<F>[] : never>}
|
|
1408
|
+
* @overload
|
|
1409
|
+
* @param {TemplateStringsArray} where
|
|
1410
|
+
* @param {...any} values
|
|
1411
|
+
* @returns {Where}
|
|
1770
1412
|
*/
|
|
1771
|
-
|
|
1413
|
+
static orNot(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1772
1414
|
/**
|
|
1773
|
-
* @
|
|
1774
|
-
* @
|
|
1775
|
-
* @param {
|
|
1776
|
-
* @
|
|
1777
|
-
* @returns {Promise<T extends Build<infer R > ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>}
|
|
1415
|
+
* @overload
|
|
1416
|
+
* @param {string} field
|
|
1417
|
+
* @param {any} value
|
|
1418
|
+
* @returns {Where}
|
|
1778
1419
|
*/
|
|
1779
|
-
|
|
1420
|
+
static orNot(field: string, value: any): Where;
|
|
1421
|
+
/**
|
|
1422
|
+
* @overload
|
|
1423
|
+
* @param {string[]} field
|
|
1424
|
+
* @param {any[]} value
|
|
1425
|
+
* @returns {Where}
|
|
1426
|
+
*/
|
|
1427
|
+
static orNot(field: string[], value: any[]): Where;
|
|
1428
|
+
/**
|
|
1429
|
+
* @overload
|
|
1430
|
+
* @param {string} field
|
|
1431
|
+
* @param {string} operator
|
|
1432
|
+
* @param {any} value
|
|
1433
|
+
* @param {boolean} [not]
|
|
1434
|
+
* @returns {Where}
|
|
1435
|
+
*/
|
|
1436
|
+
static orNot(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1437
|
+
/**
|
|
1438
|
+
* @overload
|
|
1439
|
+
* @param {string[]} field
|
|
1440
|
+
* @param {string} operator
|
|
1441
|
+
* @param {any[]} value
|
|
1442
|
+
* @param {boolean} [not]
|
|
1443
|
+
* @returns {Where}
|
|
1444
|
+
*/
|
|
1445
|
+
static orNot(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1446
|
+
/**
|
|
1447
|
+
* @overload
|
|
1448
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1449
|
+
* @returns {Where}
|
|
1450
|
+
*/
|
|
1451
|
+
static orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1780
1452
|
/**
|
|
1781
1453
|
*
|
|
1782
|
-
* @
|
|
1783
|
-
* @
|
|
1784
|
-
* @param {T} sql
|
|
1785
|
-
* @param {Skip} [skip]
|
|
1786
|
-
* @returns {Promise<T extends Build<infer R > ? R : T extends TableDefine<infer F> ? FieldValue<F> : never>}
|
|
1454
|
+
* @param {...SelectItem} subquery
|
|
1455
|
+
* @returns {Where}
|
|
1787
1456
|
*/
|
|
1788
|
-
|
|
1457
|
+
static exists(...subquery: SelectItem[]): Where;
|
|
1789
1458
|
/**
|
|
1790
|
-
*
|
|
1791
|
-
* @
|
|
1792
|
-
* @
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1459
|
+
*
|
|
1460
|
+
* @param {...SelectItem} subquery
|
|
1461
|
+
* @returns {Where}
|
|
1462
|
+
*/
|
|
1463
|
+
static notExists(...subquery: SelectItem[]): Where;
|
|
1464
|
+
toWhereValue(): WhereValue[][];
|
|
1465
|
+
/**
|
|
1466
|
+
* @overload
|
|
1467
|
+
* @param {Wheres} matches
|
|
1468
|
+
* @returns {this}
|
|
1797
1469
|
*/
|
|
1798
|
-
|
|
1470
|
+
and(matches: Wheres): this;
|
|
1799
1471
|
/**
|
|
1800
1472
|
*
|
|
1801
|
-
* @
|
|
1802
|
-
* @
|
|
1803
|
-
* @param
|
|
1804
|
-
* @
|
|
1805
|
-
* @returns {Promise<(T extends Destroy ? T : object)?>}
|
|
1473
|
+
* @overload
|
|
1474
|
+
* @param {TemplateStringsArray} where
|
|
1475
|
+
* @param {...any} values
|
|
1476
|
+
* @returns {this}
|
|
1806
1477
|
*/
|
|
1807
|
-
|
|
1478
|
+
and(where: TemplateStringsArray, ...values: any[]): this;
|
|
1808
1479
|
/**
|
|
1809
|
-
*
|
|
1810
|
-
* @
|
|
1811
|
-
* @
|
|
1812
|
-
* @
|
|
1813
|
-
* @param {T} data
|
|
1814
|
-
* @param {Record<string, SetValue>} value
|
|
1815
|
-
* @returns {Promise<(T extends PseudoDestroy ? T : object)?>}
|
|
1480
|
+
* @overload
|
|
1481
|
+
* @param {string} field
|
|
1482
|
+
* @param {any} value
|
|
1483
|
+
* @returns {this}
|
|
1816
1484
|
*/
|
|
1817
|
-
|
|
1485
|
+
and(field: string, value: any): this;
|
|
1818
1486
|
/**
|
|
1819
|
-
* @deprecated
|
|
1820
|
-
* @template {Destroy & PseudoDestroy} T
|
|
1821
1487
|
* @overload
|
|
1822
|
-
* @param {
|
|
1823
|
-
* @param {
|
|
1824
|
-
* @
|
|
1825
|
-
* @returns {Promise<T?>}
|
|
1488
|
+
* @param {string[]} field
|
|
1489
|
+
* @param {any[]} value
|
|
1490
|
+
* @returns {this}
|
|
1826
1491
|
*/
|
|
1827
|
-
|
|
1492
|
+
and(field: string[], value: any[]): this;
|
|
1828
1493
|
/**
|
|
1829
|
-
* @deprecated
|
|
1830
|
-
* @template {Destroy & PseudoDestroy} T
|
|
1831
1494
|
* @overload
|
|
1832
|
-
* @param {
|
|
1833
|
-
* @param {
|
|
1834
|
-
* @param {
|
|
1835
|
-
* @
|
|
1495
|
+
* @param {string} field
|
|
1496
|
+
* @param {string} operator
|
|
1497
|
+
* @param {any} value
|
|
1498
|
+
* @param {boolean} [not]
|
|
1499
|
+
* @returns {this}
|
|
1836
1500
|
*/
|
|
1837
|
-
|
|
1501
|
+
and(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1838
1502
|
/**
|
|
1839
|
-
* @deprecated
|
|
1840
1503
|
* @overload
|
|
1841
|
-
* @param {
|
|
1842
|
-
* @param {
|
|
1843
|
-
* @param {
|
|
1844
|
-
* @
|
|
1504
|
+
* @param {string[]} field
|
|
1505
|
+
* @param {string} operator
|
|
1506
|
+
* @param {any[]} value
|
|
1507
|
+
* @param {boolean} [not]
|
|
1508
|
+
* @returns {this}
|
|
1845
1509
|
*/
|
|
1846
|
-
|
|
1510
|
+
and(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1847
1511
|
/**
|
|
1848
|
-
* @
|
|
1849
|
-
* @param {
|
|
1850
|
-
* @
|
|
1851
|
-
* @returns {Promise<number>}
|
|
1512
|
+
* @overload
|
|
1513
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1514
|
+
* @returns {this}
|
|
1852
1515
|
*/
|
|
1853
|
-
|
|
1516
|
+
and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1854
1517
|
/**
|
|
1855
|
-
* @deprecated
|
|
1856
|
-
* @template {object} T
|
|
1857
1518
|
* @overload
|
|
1858
|
-
* @param {
|
|
1859
|
-
* @
|
|
1860
|
-
* @param {boolean} [ignoreConflict]
|
|
1861
|
-
* @returns {Promise<T>}
|
|
1519
|
+
* @param {Wheres} matches
|
|
1520
|
+
* @returns {this}
|
|
1862
1521
|
*/
|
|
1863
|
-
|
|
1522
|
+
or(matches: Wheres): this;
|
|
1864
1523
|
/**
|
|
1865
|
-
*
|
|
1866
|
-
* @template {object} T
|
|
1524
|
+
*
|
|
1867
1525
|
* @overload
|
|
1868
|
-
* @param {
|
|
1869
|
-
* @param
|
|
1870
|
-
* @
|
|
1871
|
-
* @returns {Promise<T[]>}
|
|
1526
|
+
* @param {TemplateStringsArray} where
|
|
1527
|
+
* @param {...any} values
|
|
1528
|
+
* @returns {this}
|
|
1872
1529
|
*/
|
|
1873
|
-
|
|
1530
|
+
or(where: TemplateStringsArray, ...values: any[]): this;
|
|
1874
1531
|
/**
|
|
1875
|
-
* @deprecated
|
|
1876
|
-
* @template {object} T
|
|
1877
1532
|
* @overload
|
|
1878
|
-
* @param {
|
|
1879
|
-
* @param {
|
|
1880
|
-
* @
|
|
1881
|
-
* @param {boolean} [ignoreConflict]
|
|
1882
|
-
* @returns {Promise<T>}
|
|
1533
|
+
* @param {string} field
|
|
1534
|
+
* @param {any} value
|
|
1535
|
+
* @returns {this}
|
|
1883
1536
|
*/
|
|
1884
|
-
|
|
1537
|
+
or(field: string, value: any): this;
|
|
1885
1538
|
/**
|
|
1886
|
-
* @deprecated
|
|
1887
|
-
* @template {object} T
|
|
1888
1539
|
* @overload
|
|
1889
|
-
* @param {
|
|
1890
|
-
* @param {
|
|
1891
|
-
* @
|
|
1892
|
-
* @param {boolean} [ignoreConflict]
|
|
1893
|
-
* @returns {Promise<T[]>}
|
|
1540
|
+
* @param {string[]} field
|
|
1541
|
+
* @param {any[]} value
|
|
1542
|
+
* @returns {this}
|
|
1894
1543
|
*/
|
|
1895
|
-
|
|
1544
|
+
or(field: string[], value: any[]): this;
|
|
1896
1545
|
/**
|
|
1897
|
-
* @deprecated
|
|
1898
|
-
* @template {object} T
|
|
1899
1546
|
* @overload
|
|
1900
|
-
* @param {
|
|
1901
|
-
* @param {
|
|
1902
|
-
* @param {
|
|
1903
|
-
* @param {boolean} [
|
|
1904
|
-
* @returns {
|
|
1547
|
+
* @param {string} field
|
|
1548
|
+
* @param {string} operator
|
|
1549
|
+
* @param {any} value
|
|
1550
|
+
* @param {boolean} [not]
|
|
1551
|
+
* @returns {this}
|
|
1905
1552
|
*/
|
|
1906
|
-
|
|
1553
|
+
or(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1907
1554
|
/**
|
|
1908
|
-
* @deprecated
|
|
1909
|
-
* @template {object} T
|
|
1910
1555
|
* @overload
|
|
1911
|
-
* @param {
|
|
1912
|
-
* @param {
|
|
1913
|
-
* @param {
|
|
1914
|
-
* @param {boolean} [
|
|
1915
|
-
* @returns {
|
|
1556
|
+
* @param {string[]} field
|
|
1557
|
+
* @param {string} operator
|
|
1558
|
+
* @param {any[]} value
|
|
1559
|
+
* @param {boolean} [not]
|
|
1560
|
+
* @returns {this}
|
|
1916
1561
|
*/
|
|
1917
|
-
|
|
1562
|
+
or(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1918
1563
|
/**
|
|
1919
|
-
* @deprecated
|
|
1920
|
-
* @template {object} T
|
|
1921
1564
|
* @overload
|
|
1922
|
-
* @param {
|
|
1923
|
-
* @
|
|
1924
|
-
* @param {string[] | boolean} [keys]
|
|
1925
|
-
* @param {boolean} [ignoreConflict]
|
|
1926
|
-
* @returns {Promise<T | T[]>}
|
|
1565
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1566
|
+
* @returns {this}
|
|
1927
1567
|
*/
|
|
1928
|
-
|
|
1568
|
+
or(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1929
1569
|
/**
|
|
1930
|
-
* @deprecated
|
|
1931
|
-
* @template {object} T
|
|
1932
1570
|
* @overload
|
|
1933
|
-
* @param {
|
|
1934
|
-
* @
|
|
1935
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1936
|
-
* @returns {Promise<T>}
|
|
1571
|
+
* @param {Wheres} matches
|
|
1572
|
+
* @returns {this}
|
|
1937
1573
|
*/
|
|
1938
|
-
|
|
1574
|
+
not(matches: Wheres): this;
|
|
1939
1575
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
* @template {object} T
|
|
1576
|
+
*
|
|
1942
1577
|
* @overload
|
|
1943
|
-
* @param {
|
|
1944
|
-
* @param
|
|
1945
|
-
* @
|
|
1946
|
-
* @returns {Promise<T[]>}
|
|
1578
|
+
* @param {TemplateStringsArray} where
|
|
1579
|
+
* @param {...any} values
|
|
1580
|
+
* @returns {this}
|
|
1947
1581
|
*/
|
|
1948
|
-
|
|
1582
|
+
not(where: TemplateStringsArray, ...values: any[]): this;
|
|
1949
1583
|
/**
|
|
1950
|
-
* @deprecated
|
|
1951
|
-
* @template {object} T
|
|
1952
1584
|
* @overload
|
|
1953
|
-
* @param {
|
|
1954
|
-
* @param {
|
|
1955
|
-
* @
|
|
1956
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1957
|
-
* @returns {Promise<T>}
|
|
1585
|
+
* @param {string} field
|
|
1586
|
+
* @param {any} value
|
|
1587
|
+
* @returns {this}
|
|
1958
1588
|
*/
|
|
1959
|
-
|
|
1589
|
+
not(field: string, value: any): this;
|
|
1960
1590
|
/**
|
|
1961
|
-
* @deprecated
|
|
1962
|
-
* @template {object} T
|
|
1963
1591
|
* @overload
|
|
1964
|
-
* @param {
|
|
1965
|
-
* @param {
|
|
1966
|
-
* @
|
|
1967
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1968
|
-
* @returns {Promise<T[]>}
|
|
1592
|
+
* @param {string[]} field
|
|
1593
|
+
* @param {any[]} value
|
|
1594
|
+
* @returns {this}
|
|
1969
1595
|
*/
|
|
1970
|
-
|
|
1596
|
+
not(field: string[], value: any[]): this;
|
|
1971
1597
|
/**
|
|
1972
|
-
* @deprecated
|
|
1973
|
-
* @template {object} T
|
|
1974
1598
|
* @overload
|
|
1975
|
-
* @param {
|
|
1976
|
-
* @param {
|
|
1977
|
-
* @param {
|
|
1978
|
-
* @param {
|
|
1979
|
-
* @
|
|
1980
|
-
* @returns {Promise<T>}
|
|
1599
|
+
* @param {string} field
|
|
1600
|
+
* @param {string} operator
|
|
1601
|
+
* @param {any} value
|
|
1602
|
+
* @param {boolean} [not]
|
|
1603
|
+
* @returns {this}
|
|
1981
1604
|
*/
|
|
1982
|
-
|
|
1605
|
+
not(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1983
1606
|
/**
|
|
1984
|
-
* @deprecated
|
|
1985
|
-
* @template {object} T
|
|
1986
1607
|
* @overload
|
|
1987
|
-
* @param {
|
|
1988
|
-
* @param {
|
|
1989
|
-
* @param {
|
|
1990
|
-
* @param {
|
|
1991
|
-
* @
|
|
1992
|
-
* @returns {Promise<T[]>}
|
|
1608
|
+
* @param {string[]} field
|
|
1609
|
+
* @param {string} operator
|
|
1610
|
+
* @param {any[]} value
|
|
1611
|
+
* @param {boolean} [not]
|
|
1612
|
+
* @returns {this}
|
|
1993
1613
|
*/
|
|
1994
|
-
|
|
1614
|
+
not(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1995
1615
|
/**
|
|
1996
|
-
* @deprecated
|
|
1997
|
-
* @template {object} T
|
|
1998
1616
|
* @overload
|
|
1999
|
-
* @param {
|
|
2000
|
-
* @
|
|
2001
|
-
* @param {null | string[] | boolean | Record<string, SetValue>} [keys]
|
|
2002
|
-
* @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
|
|
2003
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
2004
|
-
* @returns {Promise<T>}
|
|
1617
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1618
|
+
* @returns {this}
|
|
2005
1619
|
*/
|
|
2006
|
-
|
|
1620
|
+
not(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
2007
1621
|
/**
|
|
2008
|
-
* @deprecated
|
|
2009
|
-
* @template {object} T
|
|
2010
1622
|
* @overload
|
|
2011
|
-
* @param {
|
|
2012
|
-
* @
|
|
2013
|
-
* @param {null | string[] | boolean | Record<string, SetValue>} [keys]
|
|
2014
|
-
* @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
|
|
2015
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
2016
|
-
* @returns {Promise<T[]>}
|
|
1623
|
+
* @param {Wheres} matches
|
|
1624
|
+
* @returns {this}
|
|
2017
1625
|
*/
|
|
2018
|
-
|
|
1626
|
+
orNot(matches: Wheres): this;
|
|
2019
1627
|
/**
|
|
2020
|
-
*
|
|
2021
|
-
* @template {object} T
|
|
1628
|
+
*
|
|
2022
1629
|
* @overload
|
|
2023
|
-
* @param {
|
|
2024
|
-
* @param
|
|
2025
|
-
* @
|
|
2026
|
-
* @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
|
|
2027
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
2028
|
-
* @returns {Promise<T | T[]>}
|
|
1630
|
+
* @param {TemplateStringsArray} where
|
|
1631
|
+
* @param {...any} values
|
|
1632
|
+
* @returns {this}
|
|
2029
1633
|
*/
|
|
2030
|
-
|
|
1634
|
+
orNot(where: TemplateStringsArray, ...values: any[]): this;
|
|
2031
1635
|
/**
|
|
2032
|
-
* @
|
|
2033
|
-
* @param {
|
|
2034
|
-
* @param {
|
|
2035
|
-
* @
|
|
2036
|
-
* @param {boolean | Skip} [skip]
|
|
2037
|
-
* @returns {Promise<number>}
|
|
1636
|
+
* @overload
|
|
1637
|
+
* @param {string} field
|
|
1638
|
+
* @param {any} value
|
|
1639
|
+
* @returns {this}
|
|
2038
1640
|
*/
|
|
2039
|
-
|
|
1641
|
+
orNot(field: string, value: any): this;
|
|
2040
1642
|
/**
|
|
2041
|
-
* @
|
|
2042
|
-
* @
|
|
2043
|
-
* @param {
|
|
2044
|
-
* @
|
|
2045
|
-
* @param {string[]?} [returning]
|
|
2046
|
-
* @param {Wheres?} [where]
|
|
2047
|
-
* @param {boolean | Skip} [skip]
|
|
2048
|
-
* @returns {Promise<any[]>}
|
|
1643
|
+
* @overload
|
|
1644
|
+
* @param {string[]} field
|
|
1645
|
+
* @param {any[]} value
|
|
1646
|
+
* @returns {this}
|
|
2049
1647
|
*/
|
|
2050
|
-
|
|
1648
|
+
orNot(field: string[], value: any[]): this;
|
|
2051
1649
|
/**
|
|
2052
|
-
* @
|
|
2053
|
-
* @param {
|
|
2054
|
-
* @param {string
|
|
2055
|
-
* @param {
|
|
2056
|
-
* @param {
|
|
2057
|
-
* @
|
|
2058
|
-
* @returns {Promise<number>}
|
|
1650
|
+
* @overload
|
|
1651
|
+
* @param {string} field
|
|
1652
|
+
* @param {string} operator
|
|
1653
|
+
* @param {any} value
|
|
1654
|
+
* @param {boolean} [not]
|
|
1655
|
+
* @returns {this}
|
|
2059
1656
|
*/
|
|
2060
|
-
|
|
1657
|
+
orNot(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
2061
1658
|
/**
|
|
2062
|
-
* @
|
|
2063
|
-
* @
|
|
2064
|
-
* @param {
|
|
2065
|
-
* @param {
|
|
2066
|
-
* @param {
|
|
2067
|
-
* @
|
|
2068
|
-
* @param {string[]?} [returning]
|
|
2069
|
-
* @param {boolean | Skip} [skip]
|
|
2070
|
-
* @returns {Promise<any[]>}
|
|
1659
|
+
* @overload
|
|
1660
|
+
* @param {string[]} field
|
|
1661
|
+
* @param {string} operator
|
|
1662
|
+
* @param {any[]} value
|
|
1663
|
+
* @param {boolean} [not]
|
|
1664
|
+
* @returns {this}
|
|
2071
1665
|
*/
|
|
2072
|
-
|
|
1666
|
+
orNot(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
2073
1667
|
/**
|
|
2074
|
-
* @
|
|
2075
|
-
* @param {
|
|
2076
|
-
* @
|
|
2077
|
-
* @returns {Promise<number>}
|
|
1668
|
+
* @overload
|
|
1669
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1670
|
+
* @returns {this}
|
|
2078
1671
|
*/
|
|
2079
|
-
|
|
1672
|
+
orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
2080
1673
|
/**
|
|
2081
|
-
*
|
|
2082
|
-
* @
|
|
2083
|
-
* @
|
|
2084
|
-
* @param {string[]?} [returning]
|
|
2085
|
-
* @param {Wheres?} [where]
|
|
2086
|
-
* @returns {Promise<any[]>}
|
|
1674
|
+
*
|
|
1675
|
+
* @param {...SelectItem} subquery
|
|
1676
|
+
* @returns {this}
|
|
2087
1677
|
*/
|
|
2088
|
-
|
|
1678
|
+
exists(...subquery: SelectItem[]): this;
|
|
2089
1679
|
/**
|
|
2090
1680
|
*
|
|
2091
|
-
* @
|
|
2092
|
-
* @
|
|
2093
|
-
* @returns {Promise<number>}
|
|
1681
|
+
* @param {...SelectItem} subquery
|
|
1682
|
+
* @returns {this}
|
|
2094
1683
|
*/
|
|
1684
|
+
notExists(...subquery: SelectItem[]): this;
|
|
1685
|
+
#private;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
declare class Connection<E extends object = object> {
|
|
1689
|
+
#private;
|
|
1690
|
+
constructor(connection: PromiseLike<IConnection<E>> | IConnection<E>, transaction?: E | null);
|
|
1691
|
+
clone(): Connection<E>;
|
|
1692
|
+
call<T>(action: Action<T>): Promise<T>;
|
|
1693
|
+
dbType(): Promise<string>;
|
|
1694
|
+
dbVersion(): Promise<string>;
|
|
1695
|
+
query(...values: any[]): Promise<any[]>;
|
|
1696
|
+
exec(...values: any[]): Promise<number>;
|
|
1697
|
+
type(table: string): Promise<TableType | null>;
|
|
1698
|
+
build<T extends Fields>(build: Build<T>, data: object, saved?: object | boolean): T;
|
|
1699
|
+
build<T extends Fields>(table: TableDefine<T>, data: object, saved?: object | boolean): FieldValue<T>;
|
|
1700
|
+
build(p: Build | TableDefine, data: object, saved?: object | boolean): any;
|
|
1701
|
+
/** @deprecated */
|
|
1702
|
+
create<T extends TableDefine>(model: T, list: object[]): Promise<TableValue<T>[]>;
|
|
1703
|
+
/** @deprecated */
|
|
1704
|
+
create<T extends TableDefine>(model: T, value: object): Promise<T extends Build<infer R> ? R : TableValue<T>>;
|
|
1705
|
+
/** @deprecated */
|
|
1706
|
+
create<T extends TableDefine>(model: T, value: object | object[]): Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>;
|
|
1707
|
+
/** @deprecated */
|
|
1708
|
+
search<T extends TableDefine>(sql: T, fields: string[], skip?: Skip): Promise<T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
1709
|
+
/** @deprecated */
|
|
1710
|
+
find<T extends TableDefine>(sql: T, skip?: Skip): Promise<T extends Build<infer R> ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
1711
|
+
/** @deprecated */
|
|
1712
|
+
first<T extends TableDefine>(sql: T, skip?: Skip): Promise<T extends Build<infer R> ? R : T extends TableDefine<infer F> ? FieldValue<F> : never>;
|
|
1713
|
+
/** @deprecated */
|
|
1714
|
+
save<T>(model: TableDefine, data: T, newData?: Record<string, any> | null, skip?: Skip): Promise<(T extends Save ? T : object) | null>;
|
|
1715
|
+
/** @deprecated */
|
|
1716
|
+
completelyDestroy<T>(tableDef: TableDefine, data: T): Promise<(T extends Destroy ? T : object) | null>;
|
|
1717
|
+
/** @deprecated */
|
|
1718
|
+
pseudoDestroy<T>(tableDef: TableDefine, data: T, value: Record<string, SetValue>): Promise<(T extends PseudoDestroy ? T : object) | null>;
|
|
1719
|
+
/** @deprecated */
|
|
1720
|
+
destroy<T extends Destroy & PseudoDestroy>(table: TableDefine, data: T, update?: boolean | Record<string, any> | undefined): Promise<T | null>;
|
|
1721
|
+
/** @deprecated */
|
|
1722
|
+
destroy<T extends Destroy & PseudoDestroy>(table: TableDefine, data: T, update?: boolean | Record<string, any> | undefined): Promise<T | object | null>;
|
|
1723
|
+
/** @deprecated */
|
|
1724
|
+
destroy(table: TableDefine, data: any, update?: boolean | Record<string, any> | undefined): Promise<object | null>;
|
|
1725
|
+
/** @deprecated */
|
|
1726
|
+
destroyMany(queryable: Queryable, update?: Record<string, SetValue> | boolean): Promise<number>;
|
|
1727
|
+
/** @deprecated */
|
|
1728
|
+
insert<T>(tableDefine: TableDefine, data: T, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1729
|
+
/** @deprecated */
|
|
1730
|
+
insert<T>(tableDefine: TableDefine, data: T[], ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1731
|
+
/** @deprecated */
|
|
1732
|
+
insert<T>(tableDefine: TableDefine, data: T, keys?: string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1733
|
+
/** @deprecated */
|
|
1734
|
+
insert<T>(tableDefine: TableDefine, data: T[], keys?: string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1735
|
+
/** @deprecated */
|
|
1736
|
+
insert<T>(tableDefine: TableDefine, data: T, keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1737
|
+
/** @deprecated */
|
|
1738
|
+
insert<T>(tableDefine: TableDefine, data: T[], keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1739
|
+
/** @deprecated */
|
|
1740
|
+
insert<T>(tableDefine: TableDefine, data: T | T[], keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T | T[]>;
|
|
1741
|
+
/** @deprecated */
|
|
1742
|
+
upsert<T>(tableDefine: TableDefine, data: T, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1743
|
+
/** @deprecated */
|
|
1744
|
+
upsert<T>(tableDefine: TableDefine, data: T[], conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1745
|
+
/** @deprecated */
|
|
1746
|
+
upsert<T>(tableDefine: TableDefine, data: T, keys?: string[] | null | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1747
|
+
/** @deprecated */
|
|
1748
|
+
upsert<T>(tableDefine: TableDefine, data: T[], keys?: string[] | null | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1749
|
+
/** @deprecated */
|
|
1750
|
+
upsert<T>(tableDefine: TableDefine, data: T, keys?: string[] | null | undefined, conflictKeys?: boolean | string[] | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1751
|
+
/** @deprecated */
|
|
1752
|
+
upsert<T>(tableDefine: TableDefine, data: T[], keys?: string[] | null | undefined, conflictKeys?: boolean | string[] | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1753
|
+
/** @deprecated */
|
|
1754
|
+
upsert<T>(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>;
|
|
1755
|
+
/** @deprecated */
|
|
1756
|
+
upsert<T>(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[]>;
|
|
1757
|
+
/** @deprecated */
|
|
1758
|
+
upsert<T>(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[]>;
|
|
1759
|
+
/** @deprecated */
|
|
1760
|
+
update(table: TableDefine, update: Record<string, any>, where?: Wheres | null, skip?: boolean | Skip): Promise<number>;
|
|
1761
|
+
/** @deprecated */
|
|
1762
|
+
updateReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, update: Record<string, any>, returning?: string[] | null, where?: Wheres | null, skip?: boolean | Skip): Promise<any[]>;
|
|
1763
|
+
/** @deprecated */
|
|
1764
|
+
updateMany(table: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], skip?: boolean | Skip): Promise<number>;
|
|
1765
|
+
/** @deprecated */
|
|
1766
|
+
updateManyReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, pKeys: string[], setKeys: string[], list: Record<string, any>[], returning?: string[] | null, skip?: boolean | Skip): Promise<any[]>;
|
|
1767
|
+
/** @deprecated */
|
|
1768
|
+
delete(table: TableDefine, where?: Wheres | null): Promise<number>;
|
|
1769
|
+
/** @deprecated */
|
|
1770
|
+
deleteReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, returning?: string[] | null, where?: Wheres | null): Promise<any[]>;
|
|
1771
|
+
/** @deprecated */
|
|
2095
1772
|
count(queryable: Queryable): Promise<number>;
|
|
2096
|
-
/**
|
|
2097
|
-
* @deprecated
|
|
2098
|
-
* @param {Queryable} queryable
|
|
2099
|
-
* @returns {Promise<any[]>}
|
|
2100
|
-
*/
|
|
1773
|
+
/** @deprecated */
|
|
2101
1774
|
select(queryable: Queryable): Promise<any[]>;
|
|
2102
|
-
/**
|
|
2103
|
-
* @param {string} table
|
|
2104
|
-
* @param {string} column
|
|
2105
|
-
* @param {string} type
|
|
2106
|
-
* @param {ColumnOptions<any>} options
|
|
2107
|
-
* @returns {Promise<number>}
|
|
2108
|
-
*/
|
|
2109
1775
|
addColumn(table: string, column: string, type: string, options: ColumnOptions<any>): Promise<number>;
|
|
2110
|
-
/**
|
|
2111
|
-
* @param {string} table
|
|
2112
|
-
* @param {string} column
|
|
2113
|
-
* @param {string} type
|
|
2114
|
-
* @param {ColumnOptions<any>} options
|
|
2115
|
-
* @returns {Promise<number>}
|
|
2116
|
-
*/
|
|
2117
1776
|
changeColumn(table: string, column: string, type: string, options: ColumnOptions<any>): Promise<number>;
|
|
2118
|
-
/**
|
|
2119
|
-
* @param {string} table
|
|
2120
|
-
* @param {string} column
|
|
2121
|
-
* @param {boolean} nullable
|
|
2122
|
-
* @returns {Promise<number>}
|
|
2123
|
-
*/
|
|
2124
1777
|
changeColumnNull(table: string, column: string, nullable: boolean): Promise<number>;
|
|
2125
|
-
/**
|
|
2126
|
-
* @param {string} table
|
|
2127
|
-
* @param {string} column
|
|
2128
|
-
* @returns {Promise<number>}
|
|
2129
|
-
*/
|
|
2130
1778
|
dropColumn(table: string, column: string): Promise<number>;
|
|
2131
|
-
/**
|
|
2132
|
-
* @param {string} table
|
|
2133
|
-
* @param {string} column
|
|
2134
|
-
* @param {string} newName
|
|
2135
|
-
* @returns {Promise<number>}
|
|
2136
|
-
*/
|
|
2137
1779
|
renameColumn(table: string, column: string, newName: string): Promise<number>;
|
|
2138
|
-
/**
|
|
2139
|
-
* @param {string} table
|
|
2140
|
-
* @param {string} name
|
|
2141
|
-
* @param {string[]} fields
|
|
2142
|
-
* @param {IndexOptions} [options]
|
|
2143
|
-
* @returns {Promise<number>}
|
|
2144
|
-
*/
|
|
2145
1780
|
addIndex(table: string, name: string, fields: string[], options?: IndexOptions): Promise<number>;
|
|
2146
|
-
/**
|
|
2147
|
-
* @param {string} table
|
|
2148
|
-
* @param {string} name
|
|
2149
|
-
* @returns {Promise<number>}
|
|
2150
|
-
*/
|
|
2151
1781
|
dropIndex(table: string, name: string): Promise<number>;
|
|
2152
|
-
/**
|
|
2153
|
-
* @param {string} table
|
|
2154
|
-
* @param {Column<any>[]} fields
|
|
2155
|
-
* @returns {Promise<number>}
|
|
2156
|
-
*/
|
|
2157
1782
|
createTable(table: string, fields: Column<any>[]): Promise<number>;
|
|
2158
|
-
/**
|
|
2159
|
-
* @param {string} table
|
|
2160
|
-
* @returns {Promise<number>}
|
|
2161
|
-
*/
|
|
2162
1783
|
dropTable(table: string): Promise<number>;
|
|
2163
|
-
/**
|
|
2164
|
-
* @param {string} table
|
|
2165
|
-
* @param {string} newName
|
|
2166
|
-
* @returns {Promise<number>}
|
|
2167
|
-
*/
|
|
2168
1784
|
renameTable(table: string, newName: string): Promise<number>;
|
|
2169
|
-
abort(): boolean;
|
|
2170
|
-
/**
|
|
2171
|
-
* @returns {Promise<Savepoint>}
|
|
2172
|
-
*/
|
|
2173
|
-
savepoint(): Promise<Savepoint>;
|
|
2174
|
-
/**
|
|
2175
|
-
* @param {string} table
|
|
2176
|
-
* @returns {Promise<DBTable?>}
|
|
2177
|
-
*/
|
|
2178
1785
|
loadTable(table: string): Promise<DBTable | null>;
|
|
2179
|
-
/**
|
|
2180
|
-
* @param {string[]} tables
|
|
2181
|
-
* @returns {Promise<DBTable[]>}
|
|
2182
|
-
*/
|
|
2183
1786
|
loadTables(tables: string[]): Promise<DBTable[]>;
|
|
2184
|
-
/**
|
|
2185
|
-
* @param {TableDefine | DBTable} table
|
|
2186
|
-
* @returns {Promise<void>}
|
|
2187
|
-
*/
|
|
2188
1787
|
syncTable(table: TableDefine | DBTable): Promise<void>;
|
|
2189
|
-
/**
|
|
2190
|
-
* @param {(TableDefine | DBTable)[]} tables
|
|
2191
|
-
* @returns {Promise<void>}
|
|
2192
|
-
*/
|
|
2193
1788
|
syncTables(tables: (TableDefine | DBTable)[]): Promise<void>;
|
|
1789
|
+
abort(): boolean;
|
|
1790
|
+
savepoint(): Promise<Savepoint>;
|
|
1791
|
+
[Symbol.dispose](): void;
|
|
2194
1792
|
/**
|
|
2195
1793
|
* @template T
|
|
2196
1794
|
* @overload
|
|
2197
|
-
* @param {(t: Connection) => PromiseLike<T> | T} fn
|
|
1795
|
+
* @param {Action<T> |((t: Connection, signal: AbortSignal) => PromiseLike<T> | T)} fn
|
|
2198
1796
|
* @returns {Promise<T>}
|
|
2199
1797
|
*/
|
|
2200
|
-
transaction<T>(
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
1798
|
+
transaction<T>(list: Action<T> | ((t: Connection, signal: AbortSignal) => PromiseLike<T> | T)): Promise<Awaited<T>>;
|
|
1799
|
+
transaction<T extends readonly [] | []>(list: {
|
|
1800
|
+
[P in keyof T]: Action<T[P]> | ((t: Connection, signal: AbortSignal) => PromiseLike<T[P]> | T[P]);
|
|
1801
|
+
}): Promise<{
|
|
1802
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
1803
|
+
}>;
|
|
2205
1804
|
transaction(): TransactionHandler;
|
|
2206
|
-
[
|
|
2207
|
-
#private;
|
|
1805
|
+
transaction(fn?: (Action<any> | ((t: Connection, signal: AbortSignal) => any))[] | Action<any> | ((t: Connection, signal: AbortSignal) => any)): Promise<any> | TransactionHandler;
|
|
2208
1806
|
}
|
|
2209
1807
|
|
|
2210
1808
|
/** @import { Fields } from './types' */
|
|
@@ -2234,6 +1832,7 @@ declare class Subquery {
|
|
|
2234
1832
|
|
|
2235
1833
|
type QueryOptions<T extends Fields, TB extends unknown = any> = {
|
|
2236
1834
|
table?: string | undefined;
|
|
1835
|
+
connect?: TableConnect | null | undefined;
|
|
2237
1836
|
fields: T;
|
|
2238
1837
|
pseudo?: string | undefined;
|
|
2239
1838
|
build?: ((a: object, b?: object | boolean) => TB) | null | undefined;
|
|
@@ -2243,16 +1842,18 @@ type QueryOptions<T extends Fields, TB extends unknown = any> = {
|
|
|
2243
1842
|
* @template {object} [TB=object]
|
|
2244
1843
|
* @typedef {object} QueryOptions
|
|
2245
1844
|
* @property {string} [table]
|
|
1845
|
+
* @property {TableConnect?} [connect]
|
|
2246
1846
|
* @property {T} fields
|
|
2247
1847
|
* @property {string} [pseudo]
|
|
2248
1848
|
* @property {((a: object, b?: object | boolean) => TB)?} [build]
|
|
2249
1849
|
*/
|
|
2250
1850
|
/**
|
|
2251
1851
|
* @template {Fields} T
|
|
2252
|
-
* @template {object} [TB=object]
|
|
1852
|
+
* @template {object | never} [TB=object]
|
|
2253
1853
|
* @implements {Queryable<T>}
|
|
1854
|
+
* @implements {Action<any[]>}
|
|
2254
1855
|
*/
|
|
2255
|
-
declare class Query<T extends Fields, TB extends unknown = any> extends Subquery implements Queryable {
|
|
1856
|
+
declare class Query<T extends Fields, TB extends unknown = any> extends Subquery implements Queryable, Action {
|
|
2256
1857
|
/**
|
|
2257
1858
|
* @template {Fields} F
|
|
2258
1859
|
* @template {new (o: QueryOptions<F>) => Query<F>} T
|
|
@@ -2270,6 +1871,8 @@ declare class Query<T extends Fields, TB extends unknown = any> extends Subquery
|
|
|
2270
1871
|
constructor(options: QueryOptions<T, TB> | Query<T, TB>, noBuild?: boolean);
|
|
2271
1872
|
/** @readonly @type {string | undefined} */
|
|
2272
1873
|
readonly table: string | undefined;
|
|
1874
|
+
/** @readonly @type {TableConnect | null | undefined} */
|
|
1875
|
+
readonly connect: TableConnect | null | undefined;
|
|
2273
1876
|
/** @readonly @type {T} */
|
|
2274
1877
|
readonly fields: T;
|
|
2275
1878
|
/** @readonly @type {string} */
|
|
@@ -2434,6 +2037,18 @@ declare class Query<T extends Fields, TB extends unknown = any> extends Subquery
|
|
|
2434
2037
|
* @param {LockType?} [lock]
|
|
2435
2038
|
*/
|
|
2436
2039
|
lock(lock?: LockType | null): this;
|
|
2040
|
+
invoke(connect: any): Promise<any>;
|
|
2041
|
+
/**
|
|
2042
|
+
* @param {string[]} fields
|
|
2043
|
+
* @param {Skip} [skip]
|
|
2044
|
+
* @returns {Action<FieldValue<T>[]>}
|
|
2045
|
+
*/
|
|
2046
|
+
search(fields: string[], skip?: Skip): Action<FieldValue<T>[]>;
|
|
2047
|
+
/**
|
|
2048
|
+
* @param {Skip} [skip]
|
|
2049
|
+
* @returns {Action<(FieldValue<T> | TB)[]>}
|
|
2050
|
+
*/
|
|
2051
|
+
find(skip?: Skip): Action<(FieldValue<T> | TB)[]>;
|
|
2437
2052
|
/**
|
|
2438
2053
|
*
|
|
2439
2054
|
* @param {object} a
|
|
@@ -2475,88 +2090,100 @@ declare function mergeHooks(...hooks: (Readonly<Partial<Hooks>> | Readonly<Parti
|
|
|
2475
2090
|
*/
|
|
2476
2091
|
declare function bindHooks(hooks: Readonly<Partial<Hooks>>, that: any): Readonly<Partial<Hooks>>;
|
|
2477
2092
|
|
|
2478
|
-
declare function export_default$
|
|
2093
|
+
declare function export_default$j<T>(tableDef: TableDefine, data: T): Action<(T extends Destroy ? T : object) | null>;
|
|
2094
|
+
|
|
2095
|
+
declare function export_default$i(queryable: Queryable): Action<number>;
|
|
2479
2096
|
|
|
2480
|
-
declare function export_default$h(
|
|
2097
|
+
declare function export_default$h<T extends TableDefine>(model: T, list: object[], skip?: Skip): Action<TableValue<T>[]>;
|
|
2098
|
+
declare function export_default$h<T extends TableDefine>(model: T, value: object, skip?: Skip): Action<T extends Build<infer R> ? R : TableValue<T>>;
|
|
2099
|
+
declare function export_default$h<T extends TableDefine>(model: T, p: object | object[], skip?: Skip): Action<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>;
|
|
2481
2100
|
|
|
2482
|
-
declare function export_default$g
|
|
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>)>;
|
|
2101
|
+
declare function export_default$g({ table, connect, fields }: TableDefine, where?: Wheres | null): Action<number>;
|
|
2485
2102
|
|
|
2486
|
-
declare function export_default$f({ table, connect, fields }: TableDefine, where?: Wheres | null): Action<
|
|
2103
|
+
declare function export_default$f({ table, connect, fields }: TableDefine, returning?: string[] | null, where?: Wheres | null): Action<any[]>;
|
|
2487
2104
|
|
|
2488
|
-
declare function export_default$e(
|
|
2105
|
+
declare function export_default$e(queryable: Queryable, update?: Record<string, SetValue> | boolean): Action<number>;
|
|
2489
2106
|
|
|
2490
|
-
declare function export_default$d(
|
|
2107
|
+
declare function export_default$d<T extends Destroy & PseudoDestroy>(tableDef: TableDefine, data: T, update?: Record<string, any> | boolean): Action<T | null>;
|
|
2108
|
+
declare function export_default$d<T extends Destroy & PseudoDestroy>(tableDef: TableDefine, data: any, update?: Record<string, any> | boolean): Action<T | object | null>;
|
|
2109
|
+
declare function export_default$d(tableDef: TableDefine, data: any, update?: Record<string, any> | boolean): Action<object | null>;
|
|
2491
2110
|
|
|
2492
|
-
|
|
2493
|
-
declare function export_default$c<T extends
|
|
2494
|
-
declare function export_default$c(tableDef: TableDefine, data: any, update?: Record<string, any> | boolean): Action<object | null>;
|
|
2111
|
+
/** @deprecated */
|
|
2112
|
+
declare function export_default$c<T extends TableDefine>(sql: T, skip?: Skip): Action<T extends Build<infer R> ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
2495
2113
|
|
|
2496
|
-
declare function export_default$b<T extends TableDefine>(sql: T, skip?: Skip): Action<T extends Build<infer R> ? R
|
|
2114
|
+
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
2115
|
|
|
2498
|
-
declare function export_default$a<T extends
|
|
2116
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T[], ignoreConflict?: boolean): Action<T[]>;
|
|
2117
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T, ignoreConflict?: boolean): Action<T>;
|
|
2118
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T | T[], ignoreConflict?: boolean): Action<T | T[]>;
|
|
2119
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T[], keys?: string[], ignoreConflict?: boolean): Action<T[]>;
|
|
2120
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T, keys?: string[], ignoreConflict?: boolean): Action<T>;
|
|
2121
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: string[], ignoreConflict?: boolean): Action<T | T[]>;
|
|
2122
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T[], keys?: string[] | boolean, ignoreConflict?: boolean): Action<T[]>;
|
|
2123
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T, keys?: string[] | boolean, ignoreConflict?: boolean): Action<T>;
|
|
2124
|
+
declare function export_default$a<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: string[] | boolean, ignoreConflict?: boolean): Action<T | T[]>;
|
|
2499
2125
|
|
|
2500
|
-
declare function export_default$9<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[]>;
|
|
2126
|
+
declare function export_default$9<T>(tableDef: TableDefine, data: T, value: Record<string, SetValue>): Action<(T extends PseudoDestroy ? T : object) | null>;
|
|
2509
2127
|
|
|
2510
|
-
declare function export_default$8<T>(
|
|
2128
|
+
declare function export_default$8<T>(model: TableDefine, data: T, newData?: Record<string, any> | null, skip?: Skip): Action<(T extends Save ? T : object) | null>;
|
|
2511
2129
|
|
|
2512
|
-
|
|
2130
|
+
/** @deprecated */
|
|
2131
|
+
declare function export_default$7<T extends TableDefine>(sql: T, fields: string[], skip?: Skip): Action<T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
2513
2132
|
|
|
2514
|
-
|
|
2133
|
+
/** @deprecated */
|
|
2134
|
+
declare function export_default$6(queryable: Queryable): Action<any[]>;
|
|
2515
2135
|
|
|
2516
|
-
declare function export_default$5(
|
|
2136
|
+
declare function export_default$5({ table, connect, fields }: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], skip?: Skip | boolean): Action<number>;
|
|
2517
2137
|
|
|
2518
|
-
declare function export_default$4({ table, connect, fields }: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], skip?: Skip | boolean): Action<
|
|
2138
|
+
declare function export_default$4({ table, connect, fields }: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], returning?: string[] | null, skip?: Skip | boolean): Action<any[]>;
|
|
2519
2139
|
|
|
2520
|
-
declare function export_default$3({ table, connect, fields }: TableDefine,
|
|
2140
|
+
declare function export_default$3({ table, connect, fields }: TableDefine, update: Record<string, any>, where?: Wheres | null, skip?: Skip | boolean): Action<number>;
|
|
2521
2141
|
|
|
2522
|
-
declare function export_default$2({ table, connect, fields }: TableDefine
|
|
2142
|
+
declare function export_default$2<T extends Fields<MainFieldType>>({ table, connect, fields }: TableDefine<T>, update: Record<string, any>, returning?: string[] | null, where?: Wheres | null, skip?: Skip | boolean): Action<any[]>;
|
|
2523
2143
|
|
|
2524
|
-
declare function export_default$1<T extends
|
|
2144
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T[], conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2145
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T, conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2146
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T | T[], conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2147
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T[], keys?: null | string[], conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2148
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T, keys?: null | string[], conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2149
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: null | string[], conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2150
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T[], keys?: null | string[], conflictKeys?: string[] | boolean, conflictSet?: Record<string, SetValue>): Action<T[]>;
|
|
2151
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T, keys?: null | string[], conflictKeys?: string[] | boolean, conflictSet?: Record<string, SetValue>): Action<T>;
|
|
2152
|
+
declare function export_default$1<T extends object>(tableDefine: TableDefine, data: T | T[], keys?: null | string[], conflictKeys?: string[] | boolean, conflictSet?: Record<string, SetValue>): Action<T | T[]>;
|
|
2153
|
+
declare function export_default$1<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[]>;
|
|
2154
|
+
declare function export_default$1<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>;
|
|
2155
|
+
declare function export_default$1<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[]>;
|
|
2525
2156
|
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
declare function export_default<T extends
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
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[]>;
|
|
2157
|
+
/** @import Connection from './index.mts' */
|
|
2158
|
+
/** @import { TableDefine, Skip, SelectItem, ConnectionInterface } from '../types' */
|
|
2159
|
+
declare function export_default<T extends TableDefine>(model: T, primary: any, options?: {
|
|
2160
|
+
skipWhere?: boolean;
|
|
2161
|
+
lock?: 'S' | 'X' | null;
|
|
2162
|
+
range?: FindRange;
|
|
2163
|
+
}): Action<(T extends Build<infer R> ? R : T extends TableDefine<infer F> ? FieldValue<F> : never) | null>;
|
|
2538
2164
|
|
|
2539
2165
|
declare namespace index_d {
|
|
2540
2166
|
export {
|
|
2541
|
-
export_default$
|
|
2542
|
-
export_default$
|
|
2543
|
-
export_default$
|
|
2544
|
-
export_default$
|
|
2545
|
-
export_default$
|
|
2546
|
-
export_default$
|
|
2547
|
-
export_default$
|
|
2548
|
-
export_default$
|
|
2549
|
-
export_default$
|
|
2550
|
-
export_default
|
|
2551
|
-
export_default$
|
|
2552
|
-
export_default$
|
|
2553
|
-
export_default$
|
|
2554
|
-
export_default$
|
|
2555
|
-
export_default$
|
|
2556
|
-
export_default$
|
|
2557
|
-
export_default$
|
|
2558
|
-
export_default$
|
|
2559
|
-
export_default as
|
|
2167
|
+
export_default$j as completelyDestroy,
|
|
2168
|
+
export_default$i as count,
|
|
2169
|
+
export_default$h as create,
|
|
2170
|
+
export_default$g as delete,
|
|
2171
|
+
export_default$f as deleteReturn,
|
|
2172
|
+
export_default$d as destroy,
|
|
2173
|
+
export_default$e as destroyMany,
|
|
2174
|
+
export_default$c as find,
|
|
2175
|
+
export_default$b as first,
|
|
2176
|
+
export_default as get,
|
|
2177
|
+
export_default$a as insert,
|
|
2178
|
+
export_default$9 as pseudoDestroy,
|
|
2179
|
+
export_default$8 as save,
|
|
2180
|
+
export_default$7 as search,
|
|
2181
|
+
export_default$6 as select,
|
|
2182
|
+
export_default$3 as update,
|
|
2183
|
+
export_default$5 as updateList,
|
|
2184
|
+
export_default$4 as updateListReturn,
|
|
2185
|
+
export_default$2 as updateReturn,
|
|
2186
|
+
export_default$1 as upsert,
|
|
2560
2187
|
};
|
|
2561
2188
|
}
|
|
2562
2189
|
|
|
@@ -2974,5 +2601,5 @@ declare function toBool(v: any): boolean;
|
|
|
2974
2601
|
declare function setDevelopment(d?: boolean): void;
|
|
2975
2602
|
declare let isDevelopment: boolean;
|
|
2976
2603
|
|
|
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$
|
|
2978
|
-
export type {
|
|
2604
|
+
export { index_d as Action, Build, CheckViolationError, Connection, ConnectionError, Create, Destroy, ForeignKeyViolationError, InvalidInputSyntaxError, Model, NotNullViolationError, OperatorMismatchError, PseudoDestroy, Query, Save, Scene, Select, SetValue, Submodel, Subquery, UniqueViolationError, Where, index_d as actions, afterCreate, afterCreateMany, afterDelete, afterUpdate, beforeCreate, beforeCreateMany, beforeDelete, beforeUpdate, bindHooks, coefficient, column, export_default$j as completelyDestroy, export_default$i as count, export_default$h as create, creating, decrement, defaultValue, field as define, export_default$g as delete, export_default$f as deleteReturn, deleted, deleting, export_default$d as destroy, export_default$e as destroyMany, divide, field$1 as field, export_default$c as find, export_default$b as first, export_default as get, getPrimaryFields, getPrimaryKeys, hooks, immutable, increment, index, export_default$a as insert, isDevelopment, isPseudo, mergeHooks, model, multiply, now, primary, prop, pseudo, export_default$9 as pseudoDestroy, export_default$8 as save, export_default$7 as search, export_default$6 as select, setDevelopment, sort, model as submodel, toBool, toNot, toPrimaries, toPrimary, uncreatable, undeleted, export_default$3 as update, export_default$5 as updateList, export_default$4 as updateListReturn, export_default$2 as updateReturn, updating, export_default$1 as upsert, uuid, values, where, withDeleted };
|
|
2605
|
+
export type { 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 };
|