imodel 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +1481 -1888
- package/index.mjs +125 -564
- 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.1
|
|
3
3
|
* (c) 2019-2026 猛火Fierflame
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -28,1240 +28,403 @@ 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>>}
|
|
262
|
-
*/
|
|
263
|
-
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
264
|
-
nullable?: boolean;
|
|
265
|
-
array?: boolean;
|
|
266
|
-
default?: ToType<T, boolean, boolean> | symbol;
|
|
267
|
-
[k: string]: any;
|
|
268
|
-
} & FieldDefineOption): FieldDecorator<ToType<T, boolean, boolean>>;
|
|
269
|
-
|
|
270
|
-
/** @import { FieldDecorator } from './index.mjs' */
|
|
271
|
-
/**
|
|
272
|
-
* @param {string} prop
|
|
273
|
-
* @param {any} value
|
|
274
|
-
* @param {boolean} [array]
|
|
275
|
-
* @param {boolean} [end]
|
|
276
|
-
* @returns {FieldDecorator<any>}
|
|
277
|
-
*/
|
|
278
|
-
declare function prop(prop: string, value: any, array?: boolean, end?: boolean): FieldDecorator<any>;
|
|
279
|
-
|
|
280
|
-
/** @import { FieldDecorator } from './index.mjs' */
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
* @param {string} [column]
|
|
284
|
-
* @returns {FieldDecorator<any>}
|
|
285
|
-
*/
|
|
286
|
-
declare function column(column?: string): FieldDecorator<any>;
|
|
287
|
-
|
|
288
|
-
/** @import { FieldDecorator } from './index.mjs' */
|
|
289
|
-
/**
|
|
290
|
-
*
|
|
291
|
-
* @param {number} [primary]
|
|
292
|
-
* @returns {FieldDecorator<any>}
|
|
183
|
+
* 外键约束违规
|
|
184
|
+
* 对应 PG 23503 / MySQL 1452
|
|
185
|
+
* 场景:插入了一个不存在的 user_id
|
|
293
186
|
*/
|
|
294
|
-
declare
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
/** @
|
|
302
|
-
|
|
303
|
-
|
|
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
|
+
}
|
|
304
201
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* @param {IndexOptions} [options]
|
|
309
|
-
* @returns {ClassDecorator}
|
|
202
|
+
* 检查约束违规
|
|
203
|
+
* 对应 PG 23514
|
|
204
|
+
* 场景:年龄字段要求 > 0,但插入了 -5
|
|
310
205
|
*/
|
|
311
|
-
declare
|
|
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
|
+
}
|
|
312
217
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* @param {boolean} [unique]
|
|
317
|
-
* @returns {FieldDecorator<any>}
|
|
218
|
+
* 无效的类型输入语法错误
|
|
219
|
+
* 对应 PG 22P02
|
|
220
|
+
* 场景:无效的 UUID、日期格式错误等
|
|
318
221
|
*/
|
|
319
|
-
declare
|
|
222
|
+
declare class InvalidInputSyntaxError extends ConnectionError {
|
|
223
|
+
/**
|
|
224
|
+
* @param {string} message - 目标数据类型
|
|
225
|
+
*/
|
|
226
|
+
constructor(message: string);
|
|
227
|
+
}
|
|
320
228
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* @returns {FieldDecorator<any>}
|
|
229
|
+
* 操作符不匹配错误
|
|
230
|
+
* 对应 PG 42883
|
|
231
|
+
* 场景:uuid = integer 等类型不兼容的操作
|
|
325
232
|
*/
|
|
326
|
-
declare
|
|
233
|
+
declare class OperatorMismatchError extends ConnectionError {
|
|
234
|
+
/**
|
|
235
|
+
* @param {string} message
|
|
236
|
+
*/
|
|
237
|
+
constructor(message: string);
|
|
238
|
+
}
|
|
327
239
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
+
}
|
|
335
265
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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
|
+
}
|
|
343
274
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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;
|
|
275
|
+
type TableType = '' | 'table' | 'view';
|
|
276
|
+
interface FindArg {
|
|
277
|
+
/** 排序配置,true 表示逆序 */
|
|
278
|
+
sort?: [field: string, desc: boolean][];
|
|
279
|
+
/** 匹配信息 */
|
|
280
|
+
where: WhereValue[];
|
|
281
|
+
select: [string, Select][];
|
|
282
|
+
/** 偏移量 */
|
|
283
|
+
offset?: number;
|
|
284
|
+
/** 最大返回数 */
|
|
285
|
+
limit?: number;
|
|
527
286
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
* 对应 PG 23502 / MySQL 1048
|
|
531
|
-
* 场景:插入数据时,必填字段为空
|
|
532
|
-
*/
|
|
533
|
-
declare class NotNullViolationError extends ConnectionError {
|
|
534
|
-
/** @type {string} */
|
|
287
|
+
interface JOIN {
|
|
288
|
+
type?: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS';
|
|
535
289
|
table: string;
|
|
536
|
-
|
|
537
|
-
|
|
290
|
+
columns: Record<string, DBColumn>;
|
|
291
|
+
alias?: string;
|
|
292
|
+
condition?: WhereValue[];
|
|
538
293
|
}
|
|
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} */
|
|
294
|
+
type LockType = 'S' | 'X';
|
|
295
|
+
interface IDBTable {
|
|
552
296
|
table: string;
|
|
553
|
-
|
|
554
|
-
columns: string[];
|
|
555
|
-
/** @type {any} */
|
|
556
|
-
values: any;
|
|
297
|
+
columns: Record<string, DBColumn>;
|
|
557
298
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
*/
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
columns: string[];
|
|
574
|
-
/** @type {string} */
|
|
575
|
-
referencedTable: string;
|
|
299
|
+
interface SelectItem extends IDBTable {
|
|
300
|
+
distinct?: boolean;
|
|
301
|
+
select: [string, Select][];
|
|
302
|
+
alias?: string;
|
|
303
|
+
/** 匹配信息 */
|
|
304
|
+
where: WhereValue[];
|
|
305
|
+
group: string[];
|
|
306
|
+
having: WhereValue[];
|
|
307
|
+
/** 排序配置,true 表示逆序 */
|
|
308
|
+
sort: [field: string, desc: boolean][];
|
|
309
|
+
/** 偏移量 */
|
|
310
|
+
offset?: number;
|
|
311
|
+
/** 最大返回数 */
|
|
312
|
+
limit?: number;
|
|
313
|
+
lock?: LockType | null;
|
|
576
314
|
}
|
|
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;
|
|
315
|
+
type GetName = (table?: string) => string;
|
|
316
|
+
interface DBColumn {
|
|
317
|
+
type: string;
|
|
318
|
+
size?: number;
|
|
319
|
+
scale?: number;
|
|
320
|
+
default?: any;
|
|
321
|
+
nullable?: boolean;
|
|
322
|
+
array?: boolean;
|
|
323
|
+
primary?: number;
|
|
592
324
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
declare class InvalidInputSyntaxError extends ConnectionError {
|
|
599
|
-
/**
|
|
600
|
-
* @param {string} message - 目标数据类型
|
|
601
|
-
*/
|
|
602
|
-
constructor(message: string);
|
|
325
|
+
interface DBIndex {
|
|
326
|
+
fields: string[];
|
|
327
|
+
includes?: string[];
|
|
328
|
+
unique?: boolean;
|
|
329
|
+
name?: string;
|
|
603
330
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
declare class OperatorMismatchError extends ConnectionError {
|
|
610
|
-
/**
|
|
611
|
-
* @param {string} message
|
|
612
|
-
*/
|
|
613
|
-
constructor(message: string);
|
|
331
|
+
interface DBTable {
|
|
332
|
+
table: string;
|
|
333
|
+
fields: Record<string, DBColumn>;
|
|
334
|
+
indexes?: DBIndex[];
|
|
335
|
+
primary?: string;
|
|
614
336
|
}
|
|
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
|
-
};
|
|
337
|
+
interface Savepoint {
|
|
338
|
+
readonly name: string;
|
|
339
|
+
rollback(): Promise<void>;
|
|
340
|
+
release(): Promise<void>;
|
|
341
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
640
342
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
values:
|
|
645
|
-
|
|
343
|
+
interface ConnectionInterface {
|
|
344
|
+
dbType(): Promise<string>;
|
|
345
|
+
dbVersion(): Promise<string>;
|
|
346
|
+
query(...values: any[]): Promise<any[]>;
|
|
347
|
+
exec(...values: any[]): Promise<number>;
|
|
348
|
+
type(table: string): Promise<TableType | null>;
|
|
349
|
+
insert(table: IDBTable, data: object[], key: string[], conflictTarget?: string[] | boolean, conflictSet?: Record<string, SetValue> | boolean, conflictWhere?: WhereValue[]): PromiseLike<any[]>;
|
|
350
|
+
update(table: IDBTable, update: Record<string, SetValue>, where?: WhereValue[]): PromiseLike<number>;
|
|
351
|
+
updateReturn(returning: string[], table: IDBTable, update: Record<string, SetValue>, where?: WhereValue[]): PromiseLike<any[]>;
|
|
352
|
+
updateList(table: IDBTable, update: Record<string, any>, pKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<number>;
|
|
353
|
+
updateListReturn(returning: string[], table: IDBTable, update: Record<string, any>, primaryKeys: string[], setKeys: string[], list: Record<string, any>[], where: WhereValue[]): PromiseLike<any[]>;
|
|
354
|
+
count(table: IDBTable, where?: WhereValue[]): PromiseLike<number>;
|
|
355
|
+
select(select: SelectItem): PromiseLike<any[]>;
|
|
356
|
+
delete(table: IDBTable, where?: WhereValue[]): PromiseLike<number>;
|
|
357
|
+
deleteReturn(returning: string[], table: IDBTable, where?: WhereValue[]): PromiseLike<any[]>;
|
|
358
|
+
transaction<T>(fn: (signal: AbortSignal) => PromiseLike<T> | T): PromiseLike<T>;
|
|
359
|
+
abort(): boolean;
|
|
360
|
+
savepoint(): PromiseLike<Savepoint>;
|
|
646
361
|
}
|
|
647
|
-
interface
|
|
648
|
-
|
|
362
|
+
interface TableConnect {
|
|
363
|
+
(conn: ConnectionInterface, env: BaseEnvironment): ConnectionInterface;
|
|
649
364
|
}
|
|
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;
|
|
365
|
+
interface Action<T> {
|
|
366
|
+
invoke(connect: () => Promise<ConnectionInterface>, connection: Connection, environment: BaseEnvironment): PromiseLike<T> | T;
|
|
367
|
+
connect?: TableConnect | null;
|
|
662
368
|
}
|
|
663
|
-
|
|
664
|
-
|
|
369
|
+
interface TableConnection<E extends object = object> {
|
|
370
|
+
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[]>;
|
|
371
|
+
update(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
372
|
+
updateReturn(environment: Environment<E>, returning: string[], table: string, columns: Record<string, DBColumn>, update: Record<string, SetValue>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
373
|
+
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>;
|
|
374
|
+
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[]>;
|
|
375
|
+
count(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
376
|
+
select(environment: Environment<E>, select: SelectItem[]): PromiseLike<any[]>;
|
|
377
|
+
delete(environment: Environment<E>, table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<number>;
|
|
378
|
+
deleteReturn(environment: Environment<E>, returning: string[], table: string, columns: Record<string, DBColumn>, where?: WhereValue[] | null): PromiseLike<any[]>;
|
|
379
|
+
}
|
|
380
|
+
interface IConnection<E extends object = object> extends TableConnection<E> {
|
|
381
|
+
/** 数据库类型 */
|
|
382
|
+
readonly dbType: string;
|
|
383
|
+
/** 数据库版本 */
|
|
384
|
+
dbVersion(environment: Environment<E>): PromiseLike<string>;
|
|
385
|
+
exec(environment: Environment<E>, ...values: any): Promise<number>;
|
|
665
386
|
/**
|
|
666
|
-
*
|
|
667
|
-
* @
|
|
387
|
+
* 执行一条语句
|
|
388
|
+
* @param sql 要执行的 SQL 语句
|
|
668
389
|
*/
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
390
|
+
query(environment: Environment<E>, ...values: any): PromiseLike<any[]>;
|
|
391
|
+
type(environment: Environment<E>, table: string): PromiseLike<TableType | null>;
|
|
392
|
+
createSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
393
|
+
rollbackSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
394
|
+
releaseSavepoint(environment: Environment<E>, name: string): PromiseLike<void>;
|
|
395
|
+
createTable(environment: Environment<E>, table: string, columns: Column<any>[]): PromiseLike<number>;
|
|
396
|
+
dropTable(environment: Environment<E>, table: string): PromiseLike<number>;
|
|
397
|
+
renameTable(environment: Environment<E>, table: string, newName: string): PromiseLike<number>;
|
|
398
|
+
addColumn(environment: Environment<E>, table: string, column: string, type: string, options: ColumnOptions<any>): PromiseLike<number>;
|
|
399
|
+
changeColumn(environment: Environment<E>, table: string, column: string, type: string, options: ColumnOptions<any>): PromiseLike<number>;
|
|
400
|
+
changeColumnNull(environment: Environment<E>, table: string, column: string, nullable: boolean): PromiseLike<number>;
|
|
401
|
+
dropColumn(environment: Environment<E>, table: string, column: string): PromiseLike<number>;
|
|
402
|
+
renameColumn(environment: Environment<E>, table: string, column: string, newName: string): PromiseLike<number>;
|
|
403
|
+
addIndex(environment: Environment<E>, table: string, name: string, columns: string[], options: IndexOptions): PromiseLike<number>;
|
|
404
|
+
dropIndex(environment: Environment<E>, table: string, name: string): PromiseLike<number>;
|
|
405
|
+
loadTables(environment: Environment<E>, tables: string[]): PromiseLike<DBTable[]>;
|
|
406
|
+
syncTables(environment: Environment<E>, tables: DBTable[]): PromiseLike<void>;
|
|
407
|
+
transaction<R>(environment: Environment<E>, fn: (t: E) => R | PromiseLike<R>): PromiseLike<R>;
|
|
674
408
|
}
|
|
675
|
-
interface
|
|
676
|
-
|
|
677
|
-
|
|
409
|
+
interface Skip {
|
|
410
|
+
uncreatable?: boolean;
|
|
411
|
+
immutable?: boolean;
|
|
412
|
+
specific?: boolean;
|
|
413
|
+
where?: boolean;
|
|
678
414
|
}
|
|
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;
|
|
415
|
+
interface TransactionFn {
|
|
416
|
+
<T>(fn: (t: Connection) => PromiseLike<T> | T): Promise<T>;
|
|
417
|
+
}
|
|
418
|
+
type TransactionHandlerArray = [
|
|
419
|
+
promise: TransactionHandler['promise'],
|
|
420
|
+
commit: TransactionHandler['commit'],
|
|
421
|
+
rollback: TransactionHandler['rollback']
|
|
422
|
+
];
|
|
423
|
+
interface TransactionHandler extends TransactionHandlerArray {
|
|
424
|
+
promise: Promise<void>;
|
|
425
|
+
commit(): Promise<void>;
|
|
426
|
+
rollback(e?: any): Promise<void>;
|
|
427
|
+
[Symbol.dispose](): void;
|
|
1265
428
|
}
|
|
1266
429
|
|
|
1267
430
|
/** 字段基本类型 */
|
|
@@ -1358,853 +521,1279 @@ interface FieldTypeDefine<T extends MainFieldType = MainFieldType, A extends boo
|
|
|
1358
521
|
type: T;
|
|
1359
522
|
/** 是否可为空 */
|
|
1360
523
|
nullable: N;
|
|
1361
|
-
/** 是否为数组 */
|
|
524
|
+
/** 是否为数组 */
|
|
525
|
+
array: A;
|
|
526
|
+
}
|
|
527
|
+
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;
|
|
528
|
+
type FieldDefineType<F extends FieldTypeDefine> = F extends FieldTypeDefine<infer T, infer A, infer N> ? ToType<T, A, N> : never;
|
|
529
|
+
type Fields<T extends MainFieldType = MainFieldType> = Record<string, FieldDefine<T>>;
|
|
530
|
+
type FieldValue<T extends Fields> = {
|
|
531
|
+
[K in keyof T]: FieldDefineType<T[K]>;
|
|
532
|
+
};
|
|
533
|
+
interface IndexOptions {
|
|
534
|
+
unique?: boolean;
|
|
535
|
+
name?: string;
|
|
536
|
+
includes?: string[];
|
|
537
|
+
}
|
|
538
|
+
interface IndexInfo extends IndexOptions {
|
|
539
|
+
fields: string[];
|
|
540
|
+
}
|
|
541
|
+
interface Index extends IndexInfo {
|
|
542
|
+
name: string;
|
|
543
|
+
}
|
|
544
|
+
interface Hooks<T extends Record<string, any> = Record<string, any>> {
|
|
545
|
+
where(this: unknown, conn: Connection, model: TableDefine): PromiseLike<void | Where> | void;
|
|
546
|
+
beforeCreateMany(this: unknown, conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void | Record<string, any>[]> | void | Record<string, any>[];
|
|
547
|
+
afterCreateMany(this: unknown, conn: Connection, model: TableDefine, records: Record<string, any>[]): PromiseLike<void> | void;
|
|
548
|
+
beforeCreate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
549
|
+
afterCreate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>): PromiseLike<void> | void;
|
|
550
|
+
beforeUpdate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>, set: Record<string, any>): PromiseLike<void | Record<string, any>> | void | Record<string, any>;
|
|
551
|
+
afterUpdate(this: unknown, conn: Connection, model: TableDefine, record: Record<string, any>, oldRecord: Record<string, any>): PromiseLike<void> | void;
|
|
552
|
+
beforeDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
553
|
+
afterDelete(this: unknown, conn: Connection, model: TableDefine, record: T, update: Record<string, any> | null): PromiseLike<void> | void;
|
|
554
|
+
}
|
|
555
|
+
interface TableDefine<T extends Fields = Fields, TT extends string | undefined = string | undefined> {
|
|
556
|
+
readonly connect?: TableConnect | null;
|
|
557
|
+
/** 字段信息 */
|
|
558
|
+
readonly fields: T;
|
|
559
|
+
/** 表名 */
|
|
560
|
+
readonly table: TT;
|
|
561
|
+
/** 是否启用软删除 */
|
|
562
|
+
readonly pseudo?: string;
|
|
563
|
+
/** 索引信息 */
|
|
564
|
+
readonly indexes?: readonly IndexInfo[];
|
|
565
|
+
/** 钩子 */
|
|
566
|
+
readonly hooks?: Partial<Hooks>;
|
|
567
|
+
}
|
|
568
|
+
type TableValue<T extends TableDefine> = T extends TableDefine<infer F> ? FieldValue<F> : never;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* @template {keyof FieldType} T
|
|
572
|
+
* @overload
|
|
573
|
+
* @param {T} type
|
|
574
|
+
* @param {{
|
|
575
|
+
* nullable?: false;
|
|
576
|
+
* array?: false;
|
|
577
|
+
* default?: ToType<T, false, false> | symbol;
|
|
578
|
+
* [k: string]: any;
|
|
579
|
+
* } & FieldDefineOption} [options]
|
|
580
|
+
* @returns {FieldDecorator<ToType<T, false, false>>}
|
|
581
|
+
*/
|
|
582
|
+
declare function field$1<T extends keyof FieldType>(type: T, options?: ({
|
|
583
|
+
[k: string]: any;
|
|
584
|
+
nullable?: false;
|
|
585
|
+
array?: false;
|
|
586
|
+
default?: ToType<T, false, false> | symbol;
|
|
587
|
+
} & FieldDefineOption) | undefined): FieldDecorator<ToType<T, false, false>>;
|
|
588
|
+
/**
|
|
589
|
+
* @template {keyof FieldType} T
|
|
590
|
+
* @overload
|
|
591
|
+
* @param {T} type
|
|
592
|
+
* @param {{
|
|
593
|
+
* nullable?: false;
|
|
594
|
+
* array: true;
|
|
595
|
+
* default?: ToType<T, true, false> | symbol;
|
|
596
|
+
* [k: string]: any;
|
|
597
|
+
* } & FieldDefineOption} options
|
|
598
|
+
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
599
|
+
*/
|
|
600
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
601
|
+
nullable?: false;
|
|
602
|
+
array: true;
|
|
603
|
+
default?: ToType<T, true, false> | symbol;
|
|
604
|
+
[k: string]: any;
|
|
605
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
606
|
+
/**
|
|
607
|
+
* @template {keyof FieldType} T
|
|
608
|
+
* @overload
|
|
609
|
+
* @param {T} type
|
|
610
|
+
* @param {true} array
|
|
611
|
+
* @param {{
|
|
612
|
+
* nullable?: false;
|
|
613
|
+
* default?: ToType<T, true, false> | symbol;
|
|
614
|
+
* [k: string]: any;
|
|
615
|
+
* } & FieldDefineOption} options
|
|
616
|
+
* @returns {FieldDecorator<ToType<T, true, false>>}
|
|
617
|
+
*/
|
|
618
|
+
declare function field$1<T extends keyof FieldType>(type: T, array: true, options: {
|
|
619
|
+
nullable?: false;
|
|
620
|
+
default?: ToType<T, true, false> | symbol;
|
|
621
|
+
[k: string]: any;
|
|
622
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, false>>;
|
|
623
|
+
/**
|
|
624
|
+
* @template {keyof FieldType} T
|
|
625
|
+
* @overload
|
|
626
|
+
* @param {T} type
|
|
627
|
+
* @param {{
|
|
628
|
+
* nullable: true;
|
|
629
|
+
* array?: false;
|
|
630
|
+
* default?: ToType<T, false, true> | symbol;
|
|
631
|
+
* [k: string]: any;
|
|
632
|
+
* } & FieldDefineOption} options
|
|
633
|
+
* @returns {FieldDecorator<ToType<T, false, true>>}
|
|
634
|
+
*/
|
|
635
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
636
|
+
nullable: true;
|
|
637
|
+
array?: false;
|
|
638
|
+
default?: ToType<T, false, true> | symbol;
|
|
639
|
+
[k: string]: any;
|
|
640
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, false, true>>;
|
|
641
|
+
/**
|
|
642
|
+
* @template {keyof FieldType} T
|
|
643
|
+
* @overload
|
|
644
|
+
* @param {T} type
|
|
645
|
+
* @param {{
|
|
646
|
+
* nullable: true;
|
|
647
|
+
* array: true;
|
|
648
|
+
* default?: ToType<T, true, true> | symbol;
|
|
649
|
+
* [k: string]: any;
|
|
650
|
+
* } & FieldDefineOption} options
|
|
651
|
+
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
652
|
+
*/
|
|
653
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
654
|
+
nullable: true;
|
|
655
|
+
array: true;
|
|
656
|
+
default?: ToType<T, true, true> | symbol;
|
|
657
|
+
[k: string]: any;
|
|
658
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, true>>;
|
|
659
|
+
/**
|
|
660
|
+
* @template {keyof FieldType} T
|
|
661
|
+
* @overload
|
|
662
|
+
* @param {T} type
|
|
663
|
+
* @param {true} array
|
|
664
|
+
* @param {{
|
|
665
|
+
* nullable: true;
|
|
666
|
+
* default?: ToType<T, true, true> | symbol;
|
|
667
|
+
* [k: string]: any;
|
|
668
|
+
* } & FieldDefineOption} options
|
|
669
|
+
* @returns {FieldDecorator<ToType<T, true, true>>}
|
|
670
|
+
*/
|
|
671
|
+
declare function field$1<T extends keyof FieldType>(type: T, array: true, options: {
|
|
672
|
+
nullable: true;
|
|
673
|
+
default?: ToType<T, true, true> | symbol;
|
|
674
|
+
[k: string]: any;
|
|
675
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, true>>;
|
|
676
|
+
/**
|
|
677
|
+
* @template {keyof FieldType} T
|
|
678
|
+
* @template {boolean} A
|
|
679
|
+
* @overload
|
|
680
|
+
* @param {T} type
|
|
681
|
+
* @param {{
|
|
682
|
+
* nullable: true;
|
|
683
|
+
* array: A;
|
|
684
|
+
* default?: ToType<T, A, true> | symbol;
|
|
685
|
+
* [k: string]: any;
|
|
686
|
+
* } & FieldDefineOption} options
|
|
687
|
+
* @returns {FieldDecorator<ToType<T, A, true>>}
|
|
688
|
+
*/
|
|
689
|
+
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
690
|
+
nullable: true;
|
|
691
|
+
array: A;
|
|
692
|
+
default?: ToType<T, A, true> | symbol;
|
|
693
|
+
[k: string]: any;
|
|
694
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, A, true>>;
|
|
695
|
+
/**
|
|
696
|
+
* @template {keyof FieldType} T
|
|
697
|
+
* @template {boolean} A
|
|
698
|
+
* @overload
|
|
699
|
+
* @param {T} type
|
|
700
|
+
* @param {{
|
|
701
|
+
* nullable?: false;
|
|
702
|
+
* array: A;
|
|
703
|
+
* default?: ToType<T, A, false> | symbol;
|
|
704
|
+
* [k: string]: any;
|
|
705
|
+
* } & FieldDefineOption} options
|
|
706
|
+
* @returns {FieldDecorator<ToType<T, A, false>>}
|
|
707
|
+
*/
|
|
708
|
+
declare function field$1<T extends keyof FieldType, A extends boolean>(type: T, options: {
|
|
709
|
+
nullable?: false;
|
|
710
|
+
array: A;
|
|
711
|
+
default?: ToType<T, A, false> | symbol;
|
|
712
|
+
[k: string]: any;
|
|
713
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, A, false>>;
|
|
714
|
+
/**
|
|
715
|
+
* @template {keyof FieldType} T
|
|
716
|
+
* @template {boolean} N
|
|
717
|
+
* @overload
|
|
718
|
+
* @param {T} type
|
|
719
|
+
* @param {{
|
|
720
|
+
* nullable: N;
|
|
721
|
+
* array?: false;
|
|
722
|
+
* default?: ToType<T, false, N> | symbol;
|
|
723
|
+
* [k: string]: any;
|
|
724
|
+
* } & FieldDefineOption} options
|
|
725
|
+
* @returns {FieldDecorator<ToType<T, false, N>>}
|
|
726
|
+
*/
|
|
727
|
+
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
728
|
+
nullable: N;
|
|
729
|
+
array?: false;
|
|
730
|
+
default?: ToType<T, false, N> | symbol;
|
|
731
|
+
[k: string]: any;
|
|
732
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, false, N>>;
|
|
733
|
+
/**
|
|
734
|
+
* @template {keyof FieldType} T
|
|
735
|
+
* @template {boolean} N
|
|
736
|
+
* @overload
|
|
737
|
+
* @param {T} type
|
|
738
|
+
* @param {{
|
|
739
|
+
* nullable: N;
|
|
740
|
+
* array: true;
|
|
741
|
+
* default?: ToType<T, true, N> | symbol;
|
|
742
|
+
* [k: string]: any;
|
|
743
|
+
* } & FieldDefineOption} options
|
|
744
|
+
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
745
|
+
*/
|
|
746
|
+
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, options: {
|
|
747
|
+
nullable: N;
|
|
748
|
+
array: true;
|
|
749
|
+
default?: ToType<T, true, N> | symbol;
|
|
750
|
+
[k: string]: any;
|
|
751
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
752
|
+
/**
|
|
753
|
+
* @template {keyof FieldType} T
|
|
754
|
+
* @template {boolean} N
|
|
755
|
+
* @overload
|
|
756
|
+
* @param {T} type
|
|
757
|
+
* @param {true} array
|
|
758
|
+
* @param {{
|
|
759
|
+
* nullable: N;
|
|
760
|
+
* default?: ToType<T, true, N> | symbol;
|
|
761
|
+
* [k: string]: any;
|
|
762
|
+
* } & FieldDefineOption} options
|
|
763
|
+
* @returns {FieldDecorator<ToType<T, true, N>>}
|
|
764
|
+
*/
|
|
765
|
+
declare function field$1<T extends keyof FieldType, N extends boolean>(type: T, array: true, options: {
|
|
766
|
+
nullable: N;
|
|
767
|
+
default?: ToType<T, true, N> | symbol;
|
|
768
|
+
[k: string]: any;
|
|
769
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, true, N>>;
|
|
770
|
+
/**
|
|
771
|
+
* @template {keyof FieldType} T
|
|
772
|
+
* @template {boolean} A
|
|
773
|
+
* @template {boolean} N
|
|
774
|
+
* @overload
|
|
775
|
+
* @param {T} type
|
|
776
|
+
* @param {{
|
|
777
|
+
* nullable: N;
|
|
778
|
+
* array: A;
|
|
779
|
+
* default?: ToType<T, A, N> | symbol;
|
|
780
|
+
* [k: string]: any;
|
|
781
|
+
* } & FieldDefineOption} options
|
|
782
|
+
* @returns {FieldDecorator<ToType<T, A, N>>}
|
|
783
|
+
*/
|
|
784
|
+
declare function field$1<T extends keyof FieldType, A extends boolean, N extends boolean>(type: T, options: {
|
|
785
|
+
nullable: N;
|
|
1362
786
|
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;
|
|
787
|
+
default?: ToType<T, A, N> | symbol;
|
|
788
|
+
[k: string]: any;
|
|
789
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, A, N>>;
|
|
790
|
+
/**
|
|
791
|
+
* @template {keyof FieldType} T
|
|
792
|
+
* @overload
|
|
793
|
+
* @param {T} type
|
|
794
|
+
* @param {{
|
|
795
|
+
* nullable?: boolean;
|
|
796
|
+
* array?: boolean;
|
|
797
|
+
* default?: ToType<T, boolean, boolean> | symbol;
|
|
798
|
+
* [k: string]: any;
|
|
799
|
+
* } & FieldDefineOption} options
|
|
800
|
+
* @returns {FieldDecorator<ToType<T, boolean, boolean>>}
|
|
801
|
+
*/
|
|
802
|
+
declare function field$1<T extends keyof FieldType>(type: T, options: {
|
|
803
|
+
nullable?: boolean;
|
|
804
|
+
array?: boolean;
|
|
805
|
+
default?: ToType<T, boolean, boolean> | symbol;
|
|
806
|
+
[k: string]: any;
|
|
807
|
+
} & FieldDefineOption): FieldDecorator<ToType<T, boolean, boolean>>;
|
|
1406
808
|
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
809
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
810
|
+
/**
|
|
811
|
+
* @param {string} prop
|
|
812
|
+
* @param {any} value
|
|
813
|
+
* @param {boolean} [array]
|
|
814
|
+
* @param {boolean} [end]
|
|
815
|
+
* @returns {FieldDecorator<any>}
|
|
816
|
+
*/
|
|
817
|
+
declare function prop(prop: string, value: any, array?: boolean, end?: boolean): FieldDecorator<any>;
|
|
1414
818
|
|
|
1415
|
-
/** @
|
|
1416
|
-
/**
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
819
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
820
|
+
/**
|
|
821
|
+
*
|
|
822
|
+
* @param {string} [column]
|
|
823
|
+
* @returns {FieldDecorator<any>}
|
|
824
|
+
*/
|
|
825
|
+
declare function column(column?: string): FieldDecorator<any>;
|
|
826
|
+
|
|
827
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
828
|
+
/**
|
|
829
|
+
*
|
|
830
|
+
* @param {number} [primary]
|
|
831
|
+
* @returns {FieldDecorator<any>}
|
|
832
|
+
*/
|
|
833
|
+
declare function primary(primary?: number): FieldDecorator<any>;
|
|
834
|
+
|
|
835
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
836
|
+
/** @returns {FieldDecorator<any>} */
|
|
837
|
+
declare function uncreatable(): FieldDecorator<any>;
|
|
838
|
+
|
|
839
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
840
|
+
/** @returns {FieldDecorator<any>} */
|
|
841
|
+
declare function immutable(): FieldDecorator<any>;
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* 索引信息
|
|
845
|
+
* @overload
|
|
846
|
+
* @param {string[]} fields
|
|
847
|
+
* @param {IndexOptions} [options]
|
|
848
|
+
* @returns {ClassDecorator}
|
|
849
|
+
*/
|
|
850
|
+
declare function index(fields: string[], options?: IndexOptions | undefined): ClassDecorator;
|
|
851
|
+
/**
|
|
852
|
+
* 索引信息
|
|
853
|
+
* @overload
|
|
854
|
+
* @param {string} [name]
|
|
855
|
+
* @param {boolean} [unique]
|
|
856
|
+
* @returns {FieldDecorator<any>}
|
|
857
|
+
*/
|
|
858
|
+
declare function index(name?: string | undefined, unique?: boolean | undefined): FieldDecorator<any>;
|
|
859
|
+
/**
|
|
860
|
+
* 索引信息
|
|
861
|
+
* @overload
|
|
862
|
+
* @param {boolean} [unique]
|
|
863
|
+
* @returns {FieldDecorator<any>}
|
|
864
|
+
*/
|
|
865
|
+
declare function index(unique?: boolean | undefined): FieldDecorator<any>;
|
|
866
|
+
|
|
867
|
+
/** @import { FieldDecorator } from './index.mjs' */
|
|
868
|
+
/**
|
|
869
|
+
* 默认排序顺序,绝对值表示在排序列表中的顺序,负数表示逆序排序, 0 表示不排序
|
|
870
|
+
* @param {number} sort
|
|
871
|
+
* @returns {FieldDecorator<any>}
|
|
872
|
+
*/
|
|
873
|
+
declare function sort(sort: number): FieldDecorator<any>;
|
|
874
|
+
|
|
875
|
+
/** @import { ClassDecorator } from './index.mjs' */
|
|
876
|
+
/**
|
|
877
|
+
*
|
|
878
|
+
* @param {string} pseudo
|
|
879
|
+
* @returns {ClassDecorator}
|
|
880
|
+
*/
|
|
881
|
+
declare function pseudo(pseudo: string): ClassDecorator;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* @template T
|
|
885
|
+
* @overload
|
|
886
|
+
* @param {now} value
|
|
887
|
+
* @returns {FieldDecorator<string | Date>}
|
|
888
|
+
*/
|
|
889
|
+
declare function defaultValue<T>(value: typeof now): FieldDecorator<string | Date>;
|
|
890
|
+
/**
|
|
891
|
+
* @template T
|
|
892
|
+
* @overload
|
|
893
|
+
* @param {uuid} value
|
|
894
|
+
* @returns {FieldDecorator<string>}
|
|
895
|
+
*/
|
|
896
|
+
declare function defaultValue<T>(value: typeof uuid): FieldDecorator<string>;
|
|
897
|
+
/**
|
|
898
|
+
* @template T
|
|
899
|
+
* @overload
|
|
900
|
+
* @param {T} value
|
|
901
|
+
* @returns {FieldDecorator<T>}
|
|
902
|
+
*/
|
|
903
|
+
declare function defaultValue<T>(value: T): FieldDecorator<T>;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
*
|
|
907
|
+
* @overload
|
|
908
|
+
* @param {string} table
|
|
909
|
+
* @returns {ClassDecorator}
|
|
910
|
+
*/
|
|
911
|
+
declare function model(table: string): ClassDecorator;
|
|
1421
912
|
/**
|
|
1422
|
-
* @
|
|
1423
|
-
* @
|
|
913
|
+
* @template {Record<string, any>} T
|
|
914
|
+
* @overload
|
|
915
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
916
|
+
* @param {Record<string, Constraint>} constraints
|
|
917
|
+
* @param {true} array
|
|
918
|
+
* @param {FieldDefineOption} [options]
|
|
919
|
+
* @returns {FieldDecorator<T[]>}
|
|
1424
920
|
*/
|
|
1425
|
-
declare function
|
|
921
|
+
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
922
|
+
new (...a: any): T;
|
|
923
|
+
}, constraints: Record<string, Constraint>, array: true, options?: FieldDefineOption | undefined): FieldDecorator<T[]>;
|
|
1426
924
|
/**
|
|
1427
|
-
* @
|
|
1428
|
-
* @
|
|
925
|
+
* @template {Record<string, any>} T
|
|
926
|
+
* @overload
|
|
927
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
928
|
+
* @param {Record<string, Constraint>} constraints
|
|
929
|
+
* @param {false} [array]
|
|
930
|
+
* @param {FieldDefineOption} [options]
|
|
931
|
+
* @returns {FieldDecorator<T>}
|
|
1429
932
|
*/
|
|
1430
|
-
declare function
|
|
933
|
+
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
934
|
+
new (...a: any): T;
|
|
935
|
+
}, constraints: Record<string, Constraint>, array?: false | undefined, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
1431
936
|
/**
|
|
1432
|
-
* @
|
|
1433
|
-
* @
|
|
937
|
+
* @template {Record<string, any>} T
|
|
938
|
+
* @overload
|
|
939
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
940
|
+
* @param {Record<string, Constraint>} constraints
|
|
941
|
+
* @param {FieldDefineOption} [options]
|
|
942
|
+
* @returns {FieldDecorator<T>}
|
|
1434
943
|
*/
|
|
1435
|
-
declare function
|
|
944
|
+
declare function model<T extends Record<string, any>>(type: TableDefine & {
|
|
945
|
+
new (...a: any): T;
|
|
946
|
+
}, constraints: Record<string, Constraint>, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
1436
947
|
/**
|
|
1437
|
-
* @
|
|
1438
|
-
* @
|
|
948
|
+
* @template {Record<string, any>} T
|
|
949
|
+
* @template {boolean} [A=boolean]
|
|
950
|
+
* @overload
|
|
951
|
+
* @param {TableDefine & {new(...a: any): T}} type
|
|
952
|
+
* @param {Record<string, Constraint>} constraints
|
|
953
|
+
* @param {A} array
|
|
954
|
+
* @param {FieldDefineOption} [options]
|
|
955
|
+
* @returns {FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>}
|
|
1439
956
|
*/
|
|
1440
|
-
declare function
|
|
957
|
+
declare function model<T extends Record<string, any>, A extends boolean = boolean>(type: TableDefine & {
|
|
958
|
+
new (...a: any): T;
|
|
959
|
+
}, constraints: Record<string, Constraint>, array: A, options?: FieldDefineOption | undefined): FieldDecorator<A extends false ? T : A extends true ? T[] : T | T[]>;
|
|
1441
960
|
/**
|
|
1442
|
-
* @
|
|
1443
|
-
* @
|
|
961
|
+
* @template {object} T
|
|
962
|
+
* @overload
|
|
963
|
+
* @param {TableDefine} type
|
|
964
|
+
* @param {Record<string, Constraint>} constraints
|
|
965
|
+
* @param {true} array
|
|
966
|
+
* @param {FieldDefineOption} [options]
|
|
967
|
+
* @returns {FieldDecorator<T[]>}
|
|
1444
968
|
*/
|
|
1445
|
-
declare function
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
969
|
+
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, array: true, options?: FieldDefineOption | undefined): FieldDecorator<T[]>;
|
|
970
|
+
/**
|
|
971
|
+
* @template {object} T
|
|
972
|
+
* @overload
|
|
973
|
+
* @param {TableDefine} type
|
|
974
|
+
* @param {Record<string, Constraint>} constraints
|
|
975
|
+
* @param {false} [array]
|
|
976
|
+
* @param {FieldDefineOption} [options]
|
|
977
|
+
* @returns {FieldDecorator<T>}
|
|
978
|
+
*/
|
|
979
|
+
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, array?: false | undefined, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
980
|
+
/**
|
|
981
|
+
* @template {object} T
|
|
982
|
+
* @overload
|
|
983
|
+
* @param {TableDefine} type
|
|
984
|
+
* @param {Record<string, Constraint>} constraints
|
|
985
|
+
* @param {FieldDefineOption} [options]
|
|
986
|
+
* @returns {FieldDecorator<T>}
|
|
987
|
+
*/
|
|
988
|
+
declare function model<T extends Record<string, any>>(type: TableDefine, constraints: Record<string, Constraint>, options?: FieldDefineOption | undefined): FieldDecorator<T>;
|
|
989
|
+
/**
|
|
990
|
+
* @template {object} T
|
|
991
|
+
* @template {boolean} [A=boolean]
|
|
992
|
+
* @overload
|
|
993
|
+
* @param {TableDefine} type
|
|
994
|
+
* @param {Record<string, Constraint>} constraints
|
|
995
|
+
* @param {A} array
|
|
996
|
+
* @param {FieldDefineOption} [options]
|
|
997
|
+
* @returns {FieldDecorator<A extends false ? T :A extends true ? T[] : T | T[]>}
|
|
998
|
+
*/
|
|
999
|
+
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
1000
|
|
|
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
|
-
}
|
|
1001
|
+
/**
|
|
1002
|
+
* @param {number} [size]
|
|
1003
|
+
* @returns {FieldDecorator<Date?>}
|
|
1004
|
+
*/
|
|
1005
|
+
declare function creating(size?: number): FieldDecorator<Date | null>;
|
|
1006
|
+
/**
|
|
1007
|
+
* @param {number} [size]
|
|
1008
|
+
* @returns {FieldDecorator<Date?>}
|
|
1009
|
+
*/
|
|
1010
|
+
declare function updating(size?: number): FieldDecorator<Date | null>;
|
|
1011
|
+
/**
|
|
1012
|
+
* @param {number} [size]
|
|
1013
|
+
* @returns {FieldDecorator<Date?>}
|
|
1014
|
+
*/
|
|
1015
|
+
declare function deleting(size?: number): FieldDecorator<Date | null>;
|
|
1502
1016
|
|
|
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;
|
|
1017
|
+
/**
|
|
1018
|
+
* @overload
|
|
1019
|
+
* @param {Partial<Hooks>} hook
|
|
1020
|
+
* @param {boolean} [approach] 插入位置是否为更靠近执行的位置
|
|
1021
|
+
* @returns {ClassDecorator}
|
|
1022
|
+
*/
|
|
1023
|
+
declare function hooks(hook: Partial<Hooks>, approach?: boolean | undefined): ClassDecorator;
|
|
1024
|
+
/**
|
|
1025
|
+
* @overload
|
|
1026
|
+
* @param {Function} Model
|
|
1027
|
+
* @param {Partial<Hooks>} hook
|
|
1028
|
+
* @param {boolean} [approach] 插入位置是否为更靠近执行的位置
|
|
1029
|
+
* @returns {void}
|
|
1030
|
+
*/
|
|
1031
|
+
declare function hooks(Model: Function, hook: Partial<Hooks>, approach?: boolean | undefined): void;
|
|
1032
|
+
/** @type {Hook<Hooks['where']>} */
|
|
1033
|
+
declare const where: Hook<Hooks["where"]>;
|
|
1034
|
+
/** @type {Hook<Hooks['beforeCreateMany']>} */
|
|
1035
|
+
declare const beforeCreateMany: Hook<Hooks["beforeCreateMany"]>;
|
|
1036
|
+
/** @type {Hook<Hooks['afterCreateMany']>} */
|
|
1037
|
+
declare const afterCreateMany: Hook<Hooks["afterCreateMany"]>;
|
|
1038
|
+
/** @type {Hook<Hooks['beforeCreate']>} */
|
|
1039
|
+
declare const beforeCreate: Hook<Hooks["beforeCreate"]>;
|
|
1040
|
+
/** @type {Hook<Hooks['afterCreate']>} */
|
|
1041
|
+
declare const afterCreate: Hook<Hooks["afterCreate"]>;
|
|
1042
|
+
/** @type {Hook<Hooks['beforeUpdate']>} */
|
|
1043
|
+
declare const beforeUpdate: Hook<Hooks["beforeUpdate"]>;
|
|
1044
|
+
/** @type {Hook<Hooks['afterUpdate']>} */
|
|
1045
|
+
declare const afterUpdate: Hook<Hooks["afterUpdate"]>;
|
|
1046
|
+
/** @type {Hook<Hooks['beforeDelete']>} */
|
|
1047
|
+
declare const beforeDelete: Hook<Hooks["beforeDelete"]>;
|
|
1048
|
+
/** @type {Hook<Hooks['afterDelete']>} */
|
|
1049
|
+
declare const afterDelete: Hook<Hooks["afterDelete"]>;
|
|
1050
|
+
|
|
1051
|
+
type ClassDecorator = (val: Function, ctx: ClassDecoratorContext) => any;
|
|
1052
|
+
type FieldDecorator<T> = (val: {
|
|
1053
|
+
get(): T;
|
|
1054
|
+
set(v: T): void;
|
|
1055
|
+
}, ctx: ClassAccessorDecoratorContext) => any;
|
|
1056
|
+
type MethodDecorator<T extends Function> = (val: T, ctx: ClassMethodDecoratorContext<any, T>) => any;
|
|
1057
|
+
|
|
1058
|
+
/** 特性支持情况 */
|
|
1059
|
+
interface Support {
|
|
1060
|
+
/** 是否支持 sql 查询 */
|
|
1061
|
+
sql?: boolean;
|
|
1062
|
+
/** 是否支持数组类型 */
|
|
1550
1063
|
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;
|
|
1064
|
+
/** 是否支持对象存储 */
|
|
1065
|
+
object?: boolean;
|
|
1066
|
+
/** 是否支持递归查询 */
|
|
1067
|
+
recursive?: boolean;
|
|
1068
|
+
[key: string]: undefined | boolean;
|
|
1591
1069
|
}
|
|
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[]>;
|
|
1070
|
+
|
|
1071
|
+
type MaybePromise<T> = PromiseLike<T> | T;
|
|
1072
|
+
|
|
1073
|
+
interface Hook<T extends Hooks[keyof Hooks]> {
|
|
1074
|
+
(approach?: boolean): MethodDecorator<T>;
|
|
1075
|
+
(hook: T, approach?: boolean): ClassDecorator;
|
|
1076
|
+
(Model: Function, hook: T, approach?: boolean): void;
|
|
1602
1077
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* @param {WhereValue[]?} [items]
|
|
1081
|
+
* @returns {WhereValue[]?}
|
|
1082
|
+
*/
|
|
1083
|
+
declare function toNot(items?: WhereValue[] | null): WhereValue[] | null;
|
|
1084
|
+
type WhereItem = {
|
|
1085
|
+
exists?: false | null | undefined;
|
|
1086
|
+
where?: null | undefined;
|
|
1087
|
+
or?: null | undefined;
|
|
1088
|
+
field: string | {
|
|
1089
|
+
table?: string;
|
|
1090
|
+
field: string;
|
|
1091
|
+
} | (string | {
|
|
1092
|
+
table?: string;
|
|
1093
|
+
field: string;
|
|
1094
|
+
})[];
|
|
1095
|
+
value: any;
|
|
1096
|
+
subquery?: SelectItem[] | null | undefined;
|
|
1097
|
+
not?: boolean | undefined;
|
|
1098
|
+
operator?: string | null | undefined;
|
|
1099
|
+
};
|
|
1100
|
+
type WhereExists = {
|
|
1101
|
+
where?: null | undefined;
|
|
1102
|
+
or?: null | undefined;
|
|
1103
|
+
field?: null | undefined;
|
|
1104
|
+
exists: true;
|
|
1105
|
+
subquery: SelectItem[];
|
|
1106
|
+
not?: boolean | undefined;
|
|
1107
|
+
};
|
|
1108
|
+
type WhereRaw = {
|
|
1109
|
+
exists?: false | null | undefined;
|
|
1110
|
+
field?: null | undefined;
|
|
1111
|
+
or?: null | undefined;
|
|
1112
|
+
where: readonly string[];
|
|
1113
|
+
values: readonly any[];
|
|
1114
|
+
not?: boolean | undefined;
|
|
1115
|
+
};
|
|
1116
|
+
type WhereOr = {
|
|
1117
|
+
exists?: false | null | undefined;
|
|
1118
|
+
where?: null | undefined;
|
|
1119
|
+
field?: null | undefined;
|
|
1120
|
+
or: WhereValue[][];
|
|
1121
|
+
not?: boolean | undefined;
|
|
1122
|
+
};
|
|
1123
|
+
type WhereValue = WhereItem | WhereExists | WhereRaw | WhereOr;
|
|
1124
|
+
type WhereLike = {
|
|
1125
|
+
toWhereValue(): WhereValue[][];
|
|
1126
|
+
};
|
|
1127
|
+
type Wheres = WhereLike | Record<string, any> | (WhereLike | Record<string, any>)[];
|
|
1128
|
+
declare class Where {
|
|
1129
|
+
/**
|
|
1130
|
+
* @overload
|
|
1131
|
+
* @param {Wheres} matches
|
|
1132
|
+
* @returns {WhereValue[]?}
|
|
1133
|
+
*/
|
|
1134
|
+
static parse(matches: Wheres): WhereValue[] | null;
|
|
1135
|
+
/**
|
|
1136
|
+
* @overload
|
|
1137
|
+
* @param {string | string[]} field
|
|
1138
|
+
* @param {any} value
|
|
1139
|
+
* @returns {WhereValue[]?}
|
|
1140
|
+
*/
|
|
1141
|
+
static parse(field: string | string[], value: any): WhereValue[] | null;
|
|
1142
|
+
/**
|
|
1143
|
+
* @overload
|
|
1144
|
+
* @param {string | string[]} field
|
|
1145
|
+
* @param {string} operator
|
|
1146
|
+
* @param {any} value
|
|
1147
|
+
* @param {boolean} [not]
|
|
1148
|
+
* @returns {WhereValue[]?}
|
|
1149
|
+
*/
|
|
1150
|
+
static parse(field: string | string[], operator: string, value: any, not?: boolean | undefined): WhereValue[] | null;
|
|
1151
|
+
/**
|
|
1152
|
+
* @overload
|
|
1153
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1154
|
+
* @returns {WhereValue[]?}
|
|
1155
|
+
*/
|
|
1156
|
+
static parse(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): WhereValue[] | null;
|
|
1157
|
+
/**
|
|
1158
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1159
|
+
* @returns {WhereValue[]?}
|
|
1160
|
+
*/
|
|
1161
|
+
static parseParams(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): WhereValue[] | null;
|
|
1162
|
+
/**
|
|
1163
|
+
* @overload
|
|
1164
|
+
* @param {Wheres} matches
|
|
1165
|
+
* @returns {Where}
|
|
1166
|
+
*/
|
|
1167
|
+
static and(matches: Wheres): Where;
|
|
1168
|
+
/**
|
|
1169
|
+
*
|
|
1170
|
+
* @overload
|
|
1171
|
+
* @param {TemplateStringsArray} where
|
|
1172
|
+
* @param {...any} values
|
|
1173
|
+
* @returns {Where}
|
|
1174
|
+
*/
|
|
1175
|
+
static and(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1176
|
+
/**
|
|
1177
|
+
* @overload
|
|
1178
|
+
* @param {string} field
|
|
1179
|
+
* @param {any} value
|
|
1180
|
+
* @returns {Where}
|
|
1181
|
+
*/
|
|
1182
|
+
static and(field: string, value: any): Where;
|
|
1183
|
+
/**
|
|
1184
|
+
* @overload
|
|
1185
|
+
* @param {string[]} field
|
|
1186
|
+
* @param {any[]} value
|
|
1187
|
+
* @returns {Where}
|
|
1188
|
+
*/
|
|
1189
|
+
static and(field: string[], value: any[]): Where;
|
|
1190
|
+
/**
|
|
1191
|
+
* @overload
|
|
1192
|
+
* @param {string} field
|
|
1193
|
+
* @param {string} operator
|
|
1194
|
+
* @param {any} value
|
|
1195
|
+
* @param {boolean} [not]
|
|
1196
|
+
* @returns {Where}
|
|
1197
|
+
*/
|
|
1198
|
+
static and(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1199
|
+
/**
|
|
1200
|
+
* @overload
|
|
1201
|
+
* @param {string[]} field
|
|
1202
|
+
* @param {string} operator
|
|
1203
|
+
* @param {any[]} value
|
|
1204
|
+
* @param {boolean} [not]
|
|
1205
|
+
* @returns {Where}
|
|
1206
|
+
*/
|
|
1207
|
+
static and(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1208
|
+
/**
|
|
1209
|
+
* @overload
|
|
1210
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1211
|
+
* @returns {Where}
|
|
1212
|
+
*/
|
|
1213
|
+
static and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1214
|
+
/**
|
|
1215
|
+
* @overload
|
|
1216
|
+
* @param {Wheres} matches
|
|
1217
|
+
* @returns {Where}
|
|
1218
|
+
*/
|
|
1219
|
+
static where(matches: Wheres): Where;
|
|
1220
|
+
/**
|
|
1221
|
+
*
|
|
1222
|
+
* @overload
|
|
1223
|
+
* @param {TemplateStringsArray} where
|
|
1224
|
+
* @param {...any} values
|
|
1225
|
+
* @returns {Where}
|
|
1226
|
+
*/
|
|
1227
|
+
static where(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1228
|
+
/**
|
|
1229
|
+
* @overload
|
|
1230
|
+
* @param {string} field
|
|
1231
|
+
* @param {any} value
|
|
1232
|
+
* @returns {Where}
|
|
1233
|
+
*/
|
|
1234
|
+
static where(field: string, value: any): Where;
|
|
1235
|
+
/**
|
|
1236
|
+
* @overload
|
|
1237
|
+
* @param {string[]} field
|
|
1238
|
+
* @param {any[]} value
|
|
1239
|
+
* @returns {Where}
|
|
1240
|
+
*/
|
|
1241
|
+
static where(field: string[], value: any[]): Where;
|
|
1242
|
+
/**
|
|
1243
|
+
* @overload
|
|
1244
|
+
* @param {string} field
|
|
1245
|
+
* @param {string} operator
|
|
1246
|
+
* @param {any} value
|
|
1247
|
+
* @param {boolean} [not]
|
|
1248
|
+
* @returns {Where}
|
|
1249
|
+
*/
|
|
1250
|
+
static where(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1251
|
+
/**
|
|
1252
|
+
* @overload
|
|
1253
|
+
* @param {string[]} field
|
|
1254
|
+
* @param {string} operator
|
|
1255
|
+
* @param {any[]} value
|
|
1256
|
+
* @param {boolean} [not]
|
|
1257
|
+
* @returns {Where}
|
|
1258
|
+
*/
|
|
1259
|
+
static where(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1609
1260
|
/**
|
|
1610
|
-
*
|
|
1611
|
-
* @param
|
|
1261
|
+
* @overload
|
|
1262
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1263
|
+
* @returns {Where}
|
|
1612
1264
|
*/
|
|
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 {} = {}> {
|
|
1265
|
+
static where(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1678
1266
|
/**
|
|
1679
|
-
*
|
|
1680
|
-
* @param {
|
|
1681
|
-
* @
|
|
1267
|
+
* @overload
|
|
1268
|
+
* @param {Wheres} matches
|
|
1269
|
+
* @returns {Where}
|
|
1682
1270
|
*/
|
|
1683
|
-
|
|
1271
|
+
static or(matches: Wheres): Where;
|
|
1684
1272
|
/**
|
|
1685
1273
|
*
|
|
1686
|
-
* @
|
|
1274
|
+
* @overload
|
|
1275
|
+
* @param {TemplateStringsArray} where
|
|
1276
|
+
* @param {...any} values
|
|
1277
|
+
* @returns {Where}
|
|
1687
1278
|
*/
|
|
1688
|
-
|
|
1279
|
+
static or(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1689
1280
|
/**
|
|
1690
|
-
* @
|
|
1691
|
-
* @param {
|
|
1692
|
-
* @
|
|
1281
|
+
* @overload
|
|
1282
|
+
* @param {string} field
|
|
1283
|
+
* @param {any} value
|
|
1284
|
+
* @returns {Where}
|
|
1693
1285
|
*/
|
|
1694
|
-
|
|
1695
|
-
/** @return {Promise<string>} */
|
|
1696
|
-
dbType(): Promise<string>;
|
|
1697
|
-
/** @return {Promise<string>} */
|
|
1698
|
-
dbVersion(): Promise<string>;
|
|
1286
|
+
static or(field: string, value: any): Where;
|
|
1699
1287
|
/**
|
|
1700
|
-
*
|
|
1701
|
-
* @param {
|
|
1702
|
-
* @
|
|
1288
|
+
* @overload
|
|
1289
|
+
* @param {string[]} field
|
|
1290
|
+
* @param {any[]} value
|
|
1291
|
+
* @returns {Where}
|
|
1703
1292
|
*/
|
|
1704
|
-
|
|
1293
|
+
static or(field: string[], value: any[]): Where;
|
|
1294
|
+
/**
|
|
1295
|
+
* @overload
|
|
1296
|
+
* @param {string} field
|
|
1297
|
+
* @param {string} operator
|
|
1298
|
+
* @param {any} value
|
|
1299
|
+
* @param {boolean} [not]
|
|
1300
|
+
* @returns {Where}
|
|
1301
|
+
*/
|
|
1302
|
+
static or(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1303
|
+
/**
|
|
1304
|
+
* @overload
|
|
1305
|
+
* @param {string[]} field
|
|
1306
|
+
* @param {string} operator
|
|
1307
|
+
* @param {any[]} value
|
|
1308
|
+
* @param {boolean} [not]
|
|
1309
|
+
* @returns {Where}
|
|
1310
|
+
*/
|
|
1311
|
+
static or(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1312
|
+
/**
|
|
1313
|
+
* @overload
|
|
1314
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1315
|
+
* @returns {Where}
|
|
1316
|
+
*/
|
|
1317
|
+
static or(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1318
|
+
/**
|
|
1319
|
+
* @overload
|
|
1320
|
+
* @param {Wheres} matches
|
|
1321
|
+
* @returns {Where}
|
|
1322
|
+
*/
|
|
1323
|
+
static not(matches: Wheres): Where;
|
|
1705
1324
|
/**
|
|
1706
1325
|
*
|
|
1707
|
-
* @
|
|
1708
|
-
* @
|
|
1326
|
+
* @overload
|
|
1327
|
+
* @param {TemplateStringsArray} where
|
|
1328
|
+
* @param {...any} values
|
|
1329
|
+
* @returns {Where}
|
|
1709
1330
|
*/
|
|
1710
|
-
|
|
1331
|
+
static not(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1332
|
+
/**
|
|
1333
|
+
* @overload
|
|
1334
|
+
* @param {string} field
|
|
1335
|
+
* @param {any} value
|
|
1336
|
+
* @returns {Where}
|
|
1337
|
+
*/
|
|
1338
|
+
static not(field: string, value: any): Where;
|
|
1339
|
+
/**
|
|
1340
|
+
* @overload
|
|
1341
|
+
* @param {string[]} field
|
|
1342
|
+
* @param {any[]} value
|
|
1343
|
+
* @returns {Where}
|
|
1344
|
+
*/
|
|
1345
|
+
static not(field: string[], value: any[]): Where;
|
|
1346
|
+
/**
|
|
1347
|
+
* @overload
|
|
1348
|
+
* @param {string} field
|
|
1349
|
+
* @param {string} operator
|
|
1350
|
+
* @param {any} value
|
|
1351
|
+
* @param {boolean} [not]
|
|
1352
|
+
* @returns {Where}
|
|
1353
|
+
*/
|
|
1354
|
+
static not(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1355
|
+
/**
|
|
1356
|
+
* @overload
|
|
1357
|
+
* @param {string[]} field
|
|
1358
|
+
* @param {string} operator
|
|
1359
|
+
* @param {any[]} value
|
|
1360
|
+
* @param {boolean} [not]
|
|
1361
|
+
* @returns {Where}
|
|
1362
|
+
*/
|
|
1363
|
+
static not(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1364
|
+
/**
|
|
1365
|
+
* @overload
|
|
1366
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1367
|
+
* @returns {Where}
|
|
1368
|
+
*/
|
|
1369
|
+
static not(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1370
|
+
/**
|
|
1371
|
+
* @overload
|
|
1372
|
+
* @param {Wheres} matches
|
|
1373
|
+
* @returns {Where}
|
|
1374
|
+
*/
|
|
1375
|
+
static orNot(matches: Wheres): Where;
|
|
1711
1376
|
/**
|
|
1712
1377
|
*
|
|
1713
|
-
* @
|
|
1714
|
-
* @
|
|
1378
|
+
* @overload
|
|
1379
|
+
* @param {TemplateStringsArray} where
|
|
1380
|
+
* @param {...any} values
|
|
1381
|
+
* @returns {Where}
|
|
1715
1382
|
*/
|
|
1716
|
-
|
|
1383
|
+
static orNot(where: TemplateStringsArray, ...values: any[]): Where;
|
|
1717
1384
|
/**
|
|
1718
|
-
* @template T
|
|
1719
1385
|
* @overload
|
|
1720
|
-
* @param {
|
|
1721
|
-
* @param {
|
|
1722
|
-
* @
|
|
1723
|
-
* @returns {T}
|
|
1386
|
+
* @param {string} field
|
|
1387
|
+
* @param {any} value
|
|
1388
|
+
* @returns {Where}
|
|
1724
1389
|
*/
|
|
1725
|
-
|
|
1390
|
+
static orNot(field: string, value: any): Where;
|
|
1726
1391
|
/**
|
|
1727
|
-
* @template {Fields} T
|
|
1728
1392
|
* @overload
|
|
1729
|
-
* @param {
|
|
1730
|
-
* @param {
|
|
1731
|
-
* @
|
|
1732
|
-
* @returns {FieldValue<T>}
|
|
1393
|
+
* @param {string[]} field
|
|
1394
|
+
* @param {any[]} value
|
|
1395
|
+
* @returns {Where}
|
|
1733
1396
|
*/
|
|
1734
|
-
|
|
1397
|
+
static orNot(field: string[], value: any[]): Where;
|
|
1735
1398
|
/**
|
|
1736
|
-
* @deprecated
|
|
1737
|
-
* @template {TableDefine} T
|
|
1738
1399
|
* @overload
|
|
1739
|
-
* @param {
|
|
1740
|
-
* @param {
|
|
1741
|
-
* @
|
|
1400
|
+
* @param {string} field
|
|
1401
|
+
* @param {string} operator
|
|
1402
|
+
* @param {any} value
|
|
1403
|
+
* @param {boolean} [not]
|
|
1404
|
+
* @returns {Where}
|
|
1742
1405
|
*/
|
|
1743
|
-
|
|
1406
|
+
static orNot(field: string, operator: string, value: any, not?: boolean | undefined): Where;
|
|
1744
1407
|
/**
|
|
1745
|
-
* @deprecated
|
|
1746
|
-
* @template {TableDefine} T
|
|
1747
1408
|
* @overload
|
|
1748
|
-
* @param {
|
|
1749
|
-
* @param {
|
|
1750
|
-
* @
|
|
1409
|
+
* @param {string[]} field
|
|
1410
|
+
* @param {string} operator
|
|
1411
|
+
* @param {any[]} value
|
|
1412
|
+
* @param {boolean} [not]
|
|
1413
|
+
* @returns {Where}
|
|
1751
1414
|
*/
|
|
1752
|
-
|
|
1415
|
+
static orNot(field: string[], operator: string, value: any[], not?: boolean | undefined): Where;
|
|
1753
1416
|
/**
|
|
1754
|
-
* @deprecated
|
|
1755
|
-
* @template {TableDefine} T
|
|
1756
1417
|
* @overload
|
|
1757
|
-
* @param {
|
|
1758
|
-
* @
|
|
1759
|
-
* @returns {Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>}
|
|
1418
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1419
|
+
* @returns {Where}
|
|
1760
1420
|
*/
|
|
1761
|
-
|
|
1421
|
+
static orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): Where;
|
|
1762
1422
|
/**
|
|
1763
1423
|
*
|
|
1764
|
-
* @
|
|
1765
|
-
* @
|
|
1766
|
-
* @param {T} sql
|
|
1767
|
-
* @param {string[]} fields
|
|
1768
|
-
* @param {Skip} [skip]
|
|
1769
|
-
* @returns {Promise<T extends TableDefine<infer F> ? FieldValue<F>[] : never>}
|
|
1424
|
+
* @param {...SelectItem} subquery
|
|
1425
|
+
* @returns {Where}
|
|
1770
1426
|
*/
|
|
1771
|
-
|
|
1427
|
+
static exists(...subquery: SelectItem[]): Where;
|
|
1428
|
+
/**
|
|
1429
|
+
*
|
|
1430
|
+
* @param {...SelectItem} subquery
|
|
1431
|
+
* @returns {Where}
|
|
1432
|
+
*/
|
|
1433
|
+
static notExists(...subquery: SelectItem[]): Where;
|
|
1434
|
+
toWhereValue(): WhereValue[][];
|
|
1435
|
+
/**
|
|
1436
|
+
* @overload
|
|
1437
|
+
* @param {Wheres} matches
|
|
1438
|
+
* @returns {this}
|
|
1439
|
+
*/
|
|
1440
|
+
and(matches: Wheres): this;
|
|
1441
|
+
/**
|
|
1442
|
+
*
|
|
1443
|
+
* @overload
|
|
1444
|
+
* @param {TemplateStringsArray} where
|
|
1445
|
+
* @param {...any} values
|
|
1446
|
+
* @returns {this}
|
|
1447
|
+
*/
|
|
1448
|
+
and(where: TemplateStringsArray, ...values: any[]): this;
|
|
1449
|
+
/**
|
|
1450
|
+
* @overload
|
|
1451
|
+
* @param {string} field
|
|
1452
|
+
* @param {any} value
|
|
1453
|
+
* @returns {this}
|
|
1454
|
+
*/
|
|
1455
|
+
and(field: string, value: any): this;
|
|
1456
|
+
/**
|
|
1457
|
+
* @overload
|
|
1458
|
+
* @param {string[]} field
|
|
1459
|
+
* @param {any[]} value
|
|
1460
|
+
* @returns {this}
|
|
1461
|
+
*/
|
|
1462
|
+
and(field: string[], value: any[]): this;
|
|
1772
1463
|
/**
|
|
1773
|
-
* @
|
|
1774
|
-
* @
|
|
1775
|
-
* @param {
|
|
1776
|
-
* @param {
|
|
1777
|
-
* @
|
|
1464
|
+
* @overload
|
|
1465
|
+
* @param {string} field
|
|
1466
|
+
* @param {string} operator
|
|
1467
|
+
* @param {any} value
|
|
1468
|
+
* @param {boolean} [not]
|
|
1469
|
+
* @returns {this}
|
|
1778
1470
|
*/
|
|
1779
|
-
|
|
1471
|
+
and(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1780
1472
|
/**
|
|
1781
|
-
*
|
|
1782
|
-
* @
|
|
1783
|
-
* @
|
|
1784
|
-
* @param {
|
|
1785
|
-
* @param {
|
|
1786
|
-
* @returns {
|
|
1473
|
+
* @overload
|
|
1474
|
+
* @param {string[]} field
|
|
1475
|
+
* @param {string} operator
|
|
1476
|
+
* @param {any[]} value
|
|
1477
|
+
* @param {boolean} [not]
|
|
1478
|
+
* @returns {this}
|
|
1787
1479
|
*/
|
|
1788
|
-
|
|
1480
|
+
and(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1789
1481
|
/**
|
|
1790
|
-
* @
|
|
1791
|
-
* @
|
|
1792
|
-
* @
|
|
1793
|
-
* @param {T} data
|
|
1794
|
-
* @param {Record<string, any>?} [newData]
|
|
1795
|
-
* @param {Skip} [skip]
|
|
1796
|
-
* @returns {Promise<(T extends Save ? T : object)?>}
|
|
1482
|
+
* @overload
|
|
1483
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1484
|
+
* @returns {this}
|
|
1797
1485
|
*/
|
|
1798
|
-
|
|
1486
|
+
and(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1799
1487
|
/**
|
|
1800
|
-
*
|
|
1801
|
-
* @
|
|
1802
|
-
* @
|
|
1803
|
-
* @param {TableDefine} tableDef
|
|
1804
|
-
* @param {T} data
|
|
1805
|
-
* @returns {Promise<(T extends Destroy ? T : object)?>}
|
|
1488
|
+
* @overload
|
|
1489
|
+
* @param {Wheres} matches
|
|
1490
|
+
* @returns {this}
|
|
1806
1491
|
*/
|
|
1807
|
-
|
|
1492
|
+
or(matches: Wheres): this;
|
|
1808
1493
|
/**
|
|
1809
1494
|
*
|
|
1810
|
-
* @deprecated
|
|
1811
|
-
* @template {object} T
|
|
1812
|
-
* @param {TableDefine} tableDef
|
|
1813
|
-
* @param {T} data
|
|
1814
|
-
* @param {Record<string, SetValue>} value
|
|
1815
|
-
* @returns {Promise<(T extends PseudoDestroy ? T : object)?>}
|
|
1816
|
-
*/
|
|
1817
|
-
pseudoDestroy<T extends unknown>(tableDef: TableDefine, data: T, value: Record<string, SetValue>): Promise<(T extends PseudoDestroy ? T : object) | null>;
|
|
1818
|
-
/**
|
|
1819
|
-
* @deprecated
|
|
1820
|
-
* @template {Destroy & PseudoDestroy} T
|
|
1821
1495
|
* @overload
|
|
1822
|
-
* @param {
|
|
1823
|
-
* @param
|
|
1824
|
-
* @
|
|
1825
|
-
* @returns {Promise<T?>}
|
|
1496
|
+
* @param {TemplateStringsArray} where
|
|
1497
|
+
* @param {...any} values
|
|
1498
|
+
* @returns {this}
|
|
1826
1499
|
*/
|
|
1827
|
-
|
|
1500
|
+
or(where: TemplateStringsArray, ...values: any[]): this;
|
|
1828
1501
|
/**
|
|
1829
|
-
* @deprecated
|
|
1830
|
-
* @template {Destroy & PseudoDestroy} T
|
|
1831
1502
|
* @overload
|
|
1832
|
-
* @param {
|
|
1833
|
-
* @param {
|
|
1834
|
-
* @
|
|
1835
|
-
* @returns {Promise<T | object | null>}
|
|
1503
|
+
* @param {string} field
|
|
1504
|
+
* @param {any} value
|
|
1505
|
+
* @returns {this}
|
|
1836
1506
|
*/
|
|
1837
|
-
|
|
1507
|
+
or(field: string, value: any): this;
|
|
1838
1508
|
/**
|
|
1839
|
-
* @deprecated
|
|
1840
1509
|
* @overload
|
|
1841
|
-
* @param {
|
|
1842
|
-
* @param {any}
|
|
1843
|
-
* @
|
|
1844
|
-
* @returns {Promise<object?>}
|
|
1510
|
+
* @param {string[]} field
|
|
1511
|
+
* @param {any[]} value
|
|
1512
|
+
* @returns {this}
|
|
1845
1513
|
*/
|
|
1846
|
-
|
|
1514
|
+
or(field: string[], value: any[]): this;
|
|
1847
1515
|
/**
|
|
1848
|
-
* @
|
|
1849
|
-
* @param {
|
|
1850
|
-
* @param {
|
|
1851
|
-
* @
|
|
1516
|
+
* @overload
|
|
1517
|
+
* @param {string} field
|
|
1518
|
+
* @param {string} operator
|
|
1519
|
+
* @param {any} value
|
|
1520
|
+
* @param {boolean} [not]
|
|
1521
|
+
* @returns {this}
|
|
1852
1522
|
*/
|
|
1853
|
-
|
|
1523
|
+
or(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1854
1524
|
/**
|
|
1855
|
-
* @deprecated
|
|
1856
|
-
* @template {object} T
|
|
1857
1525
|
* @overload
|
|
1858
|
-
* @param {
|
|
1859
|
-
* @param {
|
|
1860
|
-
* @param {
|
|
1861
|
-
* @
|
|
1526
|
+
* @param {string[]} field
|
|
1527
|
+
* @param {string} operator
|
|
1528
|
+
* @param {any[]} value
|
|
1529
|
+
* @param {boolean} [not]
|
|
1530
|
+
* @returns {this}
|
|
1862
1531
|
*/
|
|
1863
|
-
|
|
1532
|
+
or(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1864
1533
|
/**
|
|
1865
|
-
* @deprecated
|
|
1866
|
-
* @template {object} T
|
|
1867
1534
|
* @overload
|
|
1868
|
-
* @param {
|
|
1869
|
-
* @
|
|
1870
|
-
* @param {boolean} [ignoreConflict]
|
|
1871
|
-
* @returns {Promise<T[]>}
|
|
1535
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1536
|
+
* @returns {this}
|
|
1872
1537
|
*/
|
|
1873
|
-
|
|
1538
|
+
or(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1874
1539
|
/**
|
|
1875
|
-
* @deprecated
|
|
1876
|
-
* @template {object} T
|
|
1877
1540
|
* @overload
|
|
1878
|
-
* @param {
|
|
1879
|
-
* @
|
|
1880
|
-
* @param {string[]} [keys]
|
|
1881
|
-
* @param {boolean} [ignoreConflict]
|
|
1882
|
-
* @returns {Promise<T>}
|
|
1541
|
+
* @param {Wheres} matches
|
|
1542
|
+
* @returns {this}
|
|
1883
1543
|
*/
|
|
1884
|
-
|
|
1544
|
+
not(matches: Wheres): this;
|
|
1885
1545
|
/**
|
|
1886
|
-
*
|
|
1887
|
-
* @template {object} T
|
|
1546
|
+
*
|
|
1888
1547
|
* @overload
|
|
1889
|
-
* @param {
|
|
1890
|
-
* @param
|
|
1891
|
-
* @
|
|
1892
|
-
* @param {boolean} [ignoreConflict]
|
|
1893
|
-
* @returns {Promise<T[]>}
|
|
1548
|
+
* @param {TemplateStringsArray} where
|
|
1549
|
+
* @param {...any} values
|
|
1550
|
+
* @returns {this}
|
|
1894
1551
|
*/
|
|
1895
|
-
|
|
1552
|
+
not(where: TemplateStringsArray, ...values: any[]): this;
|
|
1896
1553
|
/**
|
|
1897
|
-
* @deprecated
|
|
1898
|
-
* @template {object} T
|
|
1899
1554
|
* @overload
|
|
1900
|
-
* @param {
|
|
1901
|
-
* @param {
|
|
1902
|
-
* @
|
|
1903
|
-
* @param {boolean} [ignoreConflict]
|
|
1904
|
-
* @returns {Promise<T>}
|
|
1555
|
+
* @param {string} field
|
|
1556
|
+
* @param {any} value
|
|
1557
|
+
* @returns {this}
|
|
1905
1558
|
*/
|
|
1906
|
-
|
|
1559
|
+
not(field: string, value: any): this;
|
|
1907
1560
|
/**
|
|
1908
|
-
* @deprecated
|
|
1909
|
-
* @template {object} T
|
|
1910
1561
|
* @overload
|
|
1911
|
-
* @param {
|
|
1912
|
-
* @param {
|
|
1913
|
-
* @
|
|
1914
|
-
* @param {boolean} [ignoreConflict]
|
|
1915
|
-
* @returns {Promise<T[]>}
|
|
1562
|
+
* @param {string[]} field
|
|
1563
|
+
* @param {any[]} value
|
|
1564
|
+
* @returns {this}
|
|
1916
1565
|
*/
|
|
1917
|
-
|
|
1566
|
+
not(field: string[], value: any[]): this;
|
|
1918
1567
|
/**
|
|
1919
|
-
* @deprecated
|
|
1920
|
-
* @template {object} T
|
|
1921
1568
|
* @overload
|
|
1922
|
-
* @param {
|
|
1923
|
-
* @param {
|
|
1924
|
-
* @param {
|
|
1925
|
-
* @param {boolean} [
|
|
1926
|
-
* @returns {
|
|
1569
|
+
* @param {string} field
|
|
1570
|
+
* @param {string} operator
|
|
1571
|
+
* @param {any} value
|
|
1572
|
+
* @param {boolean} [not]
|
|
1573
|
+
* @returns {this}
|
|
1927
1574
|
*/
|
|
1928
|
-
|
|
1575
|
+
not(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
1929
1576
|
/**
|
|
1930
|
-
* @deprecated
|
|
1931
|
-
* @template {object} T
|
|
1932
1577
|
* @overload
|
|
1933
|
-
* @param {
|
|
1934
|
-
* @param {
|
|
1935
|
-
* @param {
|
|
1936
|
-
* @
|
|
1578
|
+
* @param {string[]} field
|
|
1579
|
+
* @param {string} operator
|
|
1580
|
+
* @param {any[]} value
|
|
1581
|
+
* @param {boolean} [not]
|
|
1582
|
+
* @returns {this}
|
|
1937
1583
|
*/
|
|
1938
|
-
|
|
1584
|
+
not(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
1939
1585
|
/**
|
|
1940
|
-
* @deprecated
|
|
1941
|
-
* @template {object} T
|
|
1942
1586
|
* @overload
|
|
1943
|
-
* @param {
|
|
1944
|
-
* @
|
|
1945
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1946
|
-
* @returns {Promise<T[]>}
|
|
1587
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1588
|
+
* @returns {this}
|
|
1947
1589
|
*/
|
|
1948
|
-
|
|
1590
|
+
not(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
1949
1591
|
/**
|
|
1950
|
-
* @deprecated
|
|
1951
|
-
* @template {object} T
|
|
1952
1592
|
* @overload
|
|
1953
|
-
* @param {
|
|
1954
|
-
* @
|
|
1955
|
-
* @param {null | string[]} [keys]
|
|
1956
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1957
|
-
* @returns {Promise<T>}
|
|
1593
|
+
* @param {Wheres} matches
|
|
1594
|
+
* @returns {this}
|
|
1958
1595
|
*/
|
|
1959
|
-
|
|
1596
|
+
orNot(matches: Wheres): this;
|
|
1960
1597
|
/**
|
|
1961
|
-
*
|
|
1962
|
-
* @template {object} T
|
|
1598
|
+
*
|
|
1963
1599
|
* @overload
|
|
1964
|
-
* @param {
|
|
1965
|
-
* @param
|
|
1966
|
-
* @
|
|
1967
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1968
|
-
* @returns {Promise<T[]>}
|
|
1600
|
+
* @param {TemplateStringsArray} where
|
|
1601
|
+
* @param {...any} values
|
|
1602
|
+
* @returns {this}
|
|
1969
1603
|
*/
|
|
1970
|
-
|
|
1604
|
+
orNot(where: TemplateStringsArray, ...values: any[]): this;
|
|
1971
1605
|
/**
|
|
1972
|
-
* @deprecated
|
|
1973
|
-
* @template {object} T
|
|
1974
1606
|
* @overload
|
|
1975
|
-
* @param {
|
|
1976
|
-
* @param {
|
|
1977
|
-
* @
|
|
1978
|
-
* @param {string[] | boolean} [conflictKeys]
|
|
1979
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1980
|
-
* @returns {Promise<T>}
|
|
1607
|
+
* @param {string} field
|
|
1608
|
+
* @param {any} value
|
|
1609
|
+
* @returns {this}
|
|
1981
1610
|
*/
|
|
1982
|
-
|
|
1611
|
+
orNot(field: string, value: any): this;
|
|
1983
1612
|
/**
|
|
1984
|
-
* @deprecated
|
|
1985
|
-
* @template {object} T
|
|
1986
1613
|
* @overload
|
|
1987
|
-
* @param {
|
|
1988
|
-
* @param {
|
|
1989
|
-
* @
|
|
1990
|
-
* @param {string[] | boolean} [conflictKeys]
|
|
1991
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
1992
|
-
* @returns {Promise<T[]>}
|
|
1614
|
+
* @param {string[]} field
|
|
1615
|
+
* @param {any[]} value
|
|
1616
|
+
* @returns {this}
|
|
1993
1617
|
*/
|
|
1994
|
-
|
|
1618
|
+
orNot(field: string[], value: any[]): this;
|
|
1995
1619
|
/**
|
|
1996
|
-
* @deprecated
|
|
1997
|
-
* @template {object} T
|
|
1998
1620
|
* @overload
|
|
1999
|
-
* @param {
|
|
2000
|
-
* @param {
|
|
2001
|
-
* @param {
|
|
2002
|
-
* @param {
|
|
2003
|
-
* @
|
|
2004
|
-
* @returns {Promise<T>}
|
|
1621
|
+
* @param {string} field
|
|
1622
|
+
* @param {string} operator
|
|
1623
|
+
* @param {any} value
|
|
1624
|
+
* @param {boolean} [not]
|
|
1625
|
+
* @returns {this}
|
|
2005
1626
|
*/
|
|
2006
|
-
|
|
1627
|
+
orNot(field: string, operator: string, value: any, not?: boolean | undefined): this;
|
|
2007
1628
|
/**
|
|
2008
|
-
* @deprecated
|
|
2009
|
-
* @template {object} T
|
|
2010
1629
|
* @overload
|
|
2011
|
-
* @param {
|
|
2012
|
-
* @param {
|
|
2013
|
-
* @param {
|
|
2014
|
-
* @param {
|
|
2015
|
-
* @
|
|
2016
|
-
* @returns {Promise<T[]>}
|
|
1630
|
+
* @param {string[]} field
|
|
1631
|
+
* @param {string} operator
|
|
1632
|
+
* @param {any[]} value
|
|
1633
|
+
* @param {boolean} [not]
|
|
1634
|
+
* @returns {this}
|
|
2017
1635
|
*/
|
|
2018
|
-
|
|
1636
|
+
orNot(field: string[], operator: string, value: any[], not?: boolean | undefined): this;
|
|
2019
1637
|
/**
|
|
2020
|
-
* @deprecated
|
|
2021
|
-
* @template {object} T
|
|
2022
1638
|
* @overload
|
|
2023
|
-
* @param {
|
|
2024
|
-
* @
|
|
2025
|
-
* @param {null | string[] | boolean | Record<string, SetValue>} [keys]
|
|
2026
|
-
* @param {string[] | boolean | Record<string, SetValue>} [conflictKeys]
|
|
2027
|
-
* @param {Record<string, SetValue>} [conflictSet]
|
|
2028
|
-
* @returns {Promise<T | T[]>}
|
|
1639
|
+
* @param {[Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]} items
|
|
1640
|
+
* @returns {this}
|
|
2029
1641
|
*/
|
|
2030
|
-
|
|
1642
|
+
orNot(items: [Wheres] | [TemplateStringsArray, ...any] | [string | string[], any] | [string | string[], string, any, boolean?]): this;
|
|
2031
1643
|
/**
|
|
2032
|
-
*
|
|
2033
|
-
* @param
|
|
2034
|
-
* @
|
|
2035
|
-
* @param {Wheres?} [where]
|
|
2036
|
-
* @param {boolean | Skip} [skip]
|
|
2037
|
-
* @returns {Promise<number>}
|
|
1644
|
+
*
|
|
1645
|
+
* @param {...SelectItem} subquery
|
|
1646
|
+
* @returns {this}
|
|
2038
1647
|
*/
|
|
2039
|
-
|
|
1648
|
+
exists(...subquery: SelectItem[]): this;
|
|
2040
1649
|
/**
|
|
2041
|
-
*
|
|
2042
|
-
* @
|
|
2043
|
-
* @
|
|
2044
|
-
* @param {Record<string, any>} update
|
|
2045
|
-
* @param {string[]?} [returning]
|
|
2046
|
-
* @param {Wheres?} [where]
|
|
2047
|
-
* @param {boolean | Skip} [skip]
|
|
2048
|
-
* @returns {Promise<any[]>}
|
|
1650
|
+
*
|
|
1651
|
+
* @param {...SelectItem} subquery
|
|
1652
|
+
* @returns {this}
|
|
2049
1653
|
*/
|
|
1654
|
+
notExists(...subquery: SelectItem[]): this;
|
|
1655
|
+
#private;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
declare const Destroy: unique symbol;
|
|
1659
|
+
interface Destroy {
|
|
1660
|
+
[Destroy](connection: Connection, run: (data: any) => Promise<object | null>, table: TableDefine<Fields<MainFieldType>>): PromiseLike<this | null>;
|
|
1661
|
+
}
|
|
1662
|
+
declare const PseudoDestroy: unique symbol;
|
|
1663
|
+
interface PseudoDestroy {
|
|
1664
|
+
[PseudoDestroy](connection: Connection, update: Record<string, SetValue>, run: (data: any) => Promise<object | null>, table: TableDefine<Fields<MainFieldType>>): PromiseLike<this | null>;
|
|
1665
|
+
}
|
|
1666
|
+
declare const Save: unique symbol;
|
|
1667
|
+
interface Save {
|
|
1668
|
+
[Save](connection: Connection, run: (data: any, newData?: any) => Promise<object | null>, newData: Record<string, any> | null, table: TableDefine): PromiseLike<this | null>;
|
|
1669
|
+
}
|
|
1670
|
+
declare const Create: unique symbol;
|
|
1671
|
+
interface Create<T = unknown> {
|
|
1672
|
+
[Create](connection: Connection, data: object, run: (data: any, that: any) => Promise<object>, table: TableDefine): PromiseLike<T>;
|
|
1673
|
+
}
|
|
1674
|
+
declare const Build: unique symbol;
|
|
1675
|
+
interface Build<T = unknown> {
|
|
1676
|
+
[Build](data: object, others: object | boolean): T;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
declare class Connection<E extends object = object> {
|
|
1680
|
+
#private;
|
|
1681
|
+
constructor(connection: PromiseLike<IConnection<E>> | IConnection<E>, transaction?: E | null);
|
|
1682
|
+
clone(): Connection<E>;
|
|
1683
|
+
call<T>(action: Action<T>): Promise<T>;
|
|
1684
|
+
dbType(): Promise<string>;
|
|
1685
|
+
dbVersion(): Promise<string>;
|
|
1686
|
+
query(...values: any[]): Promise<any[]>;
|
|
1687
|
+
exec(...values: any[]): Promise<number>;
|
|
1688
|
+
type(table: string): Promise<TableType | null>;
|
|
1689
|
+
build<T extends Fields>(build: Build<T>, data: object, saved?: object | boolean): T;
|
|
1690
|
+
build<T extends Fields>(table: TableDefine<T>, data: object, saved?: object | boolean): FieldValue<T>;
|
|
1691
|
+
build(p: Build | TableDefine, data: object, saved?: object | boolean): any;
|
|
1692
|
+
/** @deprecated */
|
|
1693
|
+
create<T extends TableDefine>(model: T, list: object[]): Promise<TableValue<T>[]>;
|
|
1694
|
+
/** @deprecated */
|
|
1695
|
+
create<T extends TableDefine>(model: T, value: object): Promise<T extends Build<infer R> ? R : TableValue<T>>;
|
|
1696
|
+
/** @deprecated */
|
|
1697
|
+
create<T extends TableDefine>(model: T, value: object | object[]): Promise<TableValue<T>[] | (T extends Build<infer R> ? R : TableValue<T>)>;
|
|
1698
|
+
/** @deprecated */
|
|
1699
|
+
search<T extends TableDefine>(sql: T, fields: string[], skip?: Skip): Promise<T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
1700
|
+
/** @deprecated */
|
|
1701
|
+
find<T extends TableDefine>(sql: T, skip?: Skip): Promise<T extends Build<infer R> ? R[] : T extends TableDefine<infer F> ? FieldValue<F>[] : never>;
|
|
1702
|
+
/** @deprecated */
|
|
1703
|
+
first<T extends TableDefine>(sql: T, skip?: Skip): Promise<T extends Build<infer R> ? R : T extends TableDefine<infer F> ? FieldValue<F> : never>;
|
|
1704
|
+
/** @deprecated */
|
|
1705
|
+
save<T>(model: TableDefine, data: T, newData?: Record<string, any> | null, skip?: Skip): Promise<(T extends Save ? T : object) | null>;
|
|
1706
|
+
/** @deprecated */
|
|
1707
|
+
completelyDestroy<T>(tableDef: TableDefine, data: T): Promise<(T extends Destroy ? T : object) | null>;
|
|
1708
|
+
/** @deprecated */
|
|
1709
|
+
pseudoDestroy<T>(tableDef: TableDefine, data: T, value: Record<string, SetValue>): Promise<(T extends PseudoDestroy ? T : object) | null>;
|
|
1710
|
+
/** @deprecated */
|
|
1711
|
+
destroy<T extends Destroy & PseudoDestroy>(table: TableDefine, data: T, update?: boolean | Record<string, any> | undefined): Promise<T | null>;
|
|
1712
|
+
/** @deprecated */
|
|
1713
|
+
destroy<T extends Destroy & PseudoDestroy>(table: TableDefine, data: T, update?: boolean | Record<string, any> | undefined): Promise<T | object | null>;
|
|
1714
|
+
/** @deprecated */
|
|
1715
|
+
destroy(table: TableDefine, data: any, update?: boolean | Record<string, any> | undefined): Promise<object | null>;
|
|
1716
|
+
/** @deprecated */
|
|
1717
|
+
destroyMany(queryable: Queryable, update?: Record<string, SetValue> | boolean): Promise<number>;
|
|
1718
|
+
/** @deprecated */
|
|
1719
|
+
insert<T>(tableDefine: TableDefine, data: T, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1720
|
+
/** @deprecated */
|
|
1721
|
+
insert<T>(tableDefine: TableDefine, data: T[], ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1722
|
+
/** @deprecated */
|
|
1723
|
+
insert<T>(tableDefine: TableDefine, data: T, keys?: string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1724
|
+
/** @deprecated */
|
|
1725
|
+
insert<T>(tableDefine: TableDefine, data: T[], keys?: string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1726
|
+
/** @deprecated */
|
|
1727
|
+
insert<T>(tableDefine: TableDefine, data: T, keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T>;
|
|
1728
|
+
/** @deprecated */
|
|
1729
|
+
insert<T>(tableDefine: TableDefine, data: T[], keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T[]>;
|
|
1730
|
+
/** @deprecated */
|
|
1731
|
+
insert<T>(tableDefine: TableDefine, data: T | T[], keys?: boolean | string[] | undefined, ignoreConflict?: boolean | undefined): Promise<T | T[]>;
|
|
1732
|
+
/** @deprecated */
|
|
1733
|
+
upsert<T>(tableDefine: TableDefine, data: T, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1734
|
+
/** @deprecated */
|
|
1735
|
+
upsert<T>(tableDefine: TableDefine, data: T[], conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1736
|
+
/** @deprecated */
|
|
1737
|
+
upsert<T>(tableDefine: TableDefine, data: T, keys?: string[] | null | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1738
|
+
/** @deprecated */
|
|
1739
|
+
upsert<T>(tableDefine: TableDefine, data: T[], keys?: string[] | null | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1740
|
+
/** @deprecated */
|
|
1741
|
+
upsert<T>(tableDefine: TableDefine, data: T, keys?: string[] | null | undefined, conflictKeys?: boolean | string[] | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T>;
|
|
1742
|
+
/** @deprecated */
|
|
1743
|
+
upsert<T>(tableDefine: TableDefine, data: T[], keys?: string[] | null | undefined, conflictKeys?: boolean | string[] | undefined, conflictSet?: Record<string, SetValue> | undefined): Promise<T[]>;
|
|
1744
|
+
/** @deprecated */
|
|
1745
|
+
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>;
|
|
1746
|
+
/** @deprecated */
|
|
1747
|
+
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[]>;
|
|
1748
|
+
/** @deprecated */
|
|
1749
|
+
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[]>;
|
|
1750
|
+
/** @deprecated */
|
|
1751
|
+
update(table: TableDefine, update: Record<string, any>, where?: Wheres | null, skip?: boolean | Skip): Promise<number>;
|
|
1752
|
+
/** @deprecated */
|
|
2050
1753
|
updateReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, update: Record<string, any>, returning?: string[] | null, where?: Wheres | null, skip?: boolean | Skip): Promise<any[]>;
|
|
2051
|
-
/**
|
|
2052
|
-
* @deprecated
|
|
2053
|
-
* @param {TableDefine} table
|
|
2054
|
-
* @param {string[]} pKeys
|
|
2055
|
-
* @param {string[]} setKeys
|
|
2056
|
-
* @param {Record<string, any>[]} list
|
|
2057
|
-
* @param {boolean | Skip} [skip]
|
|
2058
|
-
* @returns {Promise<number>}
|
|
2059
|
-
*/
|
|
1754
|
+
/** @deprecated */
|
|
2060
1755
|
updateMany(table: TableDefine, pKeys: string[], setKeys: string[], list: Record<string, any>[], skip?: boolean | Skip): Promise<number>;
|
|
2061
|
-
/**
|
|
2062
|
-
* @deprecated
|
|
2063
|
-
* @template {Fields<MainFieldType>} T
|
|
2064
|
-
* @param {TableDefine<T>} table
|
|
2065
|
-
* @param {string[]} pKeys
|
|
2066
|
-
* @param {string[]} setKeys
|
|
2067
|
-
* @param {Record<string, any>[]} list
|
|
2068
|
-
* @param {string[]?} [returning]
|
|
2069
|
-
* @param {boolean | Skip} [skip]
|
|
2070
|
-
* @returns {Promise<any[]>}
|
|
2071
|
-
*/
|
|
1756
|
+
/** @deprecated */
|
|
2072
1757
|
updateManyReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, pKeys: string[], setKeys: string[], list: Record<string, any>[], returning?: string[] | null, skip?: boolean | Skip): Promise<any[]>;
|
|
2073
|
-
/**
|
|
2074
|
-
* @deprecated
|
|
2075
|
-
* @param {TableDefine} table
|
|
2076
|
-
* @param {Wheres?} [where]
|
|
2077
|
-
* @returns {Promise<number>}
|
|
2078
|
-
*/
|
|
1758
|
+
/** @deprecated */
|
|
2079
1759
|
delete(table: TableDefine, where?: Wheres | null): Promise<number>;
|
|
2080
|
-
/**
|
|
2081
|
-
* @deprecated
|
|
2082
|
-
* @template {Fields<MainFieldType>} T
|
|
2083
|
-
* @param {TableDefine<T>} table
|
|
2084
|
-
* @param {string[]?} [returning]
|
|
2085
|
-
* @param {Wheres?} [where]
|
|
2086
|
-
* @returns {Promise<any[]>}
|
|
2087
|
-
*/
|
|
1760
|
+
/** @deprecated */
|
|
2088
1761
|
deleteReturn<T extends Fields<MainFieldType>>(table: TableDefine<T>, returning?: string[] | null, where?: Wheres | null): Promise<any[]>;
|
|
2089
|
-
/**
|
|
2090
|
-
*
|
|
2091
|
-
* @deprecated
|
|
2092
|
-
* @param {Queryable} queryable
|
|
2093
|
-
* @returns {Promise<number>}
|
|
2094
|
-
*/
|
|
1762
|
+
/** @deprecated */
|
|
2095
1763
|
count(queryable: Queryable): Promise<number>;
|
|
2096
|
-
/**
|
|
2097
|
-
* @deprecated
|
|
2098
|
-
* @param {Queryable} queryable
|
|
2099
|
-
* @returns {Promise<any[]>}
|
|
2100
|
-
*/
|
|
1764
|
+
/** @deprecated */
|
|
2101
1765
|
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
1766
|
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
1767
|
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
1768
|
changeColumnNull(table: string, column: string, nullable: boolean): Promise<number>;
|
|
2125
|
-
/**
|
|
2126
|
-
* @param {string} table
|
|
2127
|
-
* @param {string} column
|
|
2128
|
-
* @returns {Promise<number>}
|
|
2129
|
-
*/
|
|
2130
1769
|
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
1770
|
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
1771
|
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
1772
|
dropIndex(table: string, name: string): Promise<number>;
|
|
2152
|
-
/**
|
|
2153
|
-
* @param {string} table
|
|
2154
|
-
* @param {Column<any>[]} fields
|
|
2155
|
-
* @returns {Promise<number>}
|
|
2156
|
-
*/
|
|
2157
1773
|
createTable(table: string, fields: Column<any>[]): Promise<number>;
|
|
2158
|
-
/**
|
|
2159
|
-
* @param {string} table
|
|
2160
|
-
* @returns {Promise<number>}
|
|
2161
|
-
*/
|
|
2162
1774
|
dropTable(table: string): Promise<number>;
|
|
2163
|
-
/**
|
|
2164
|
-
* @param {string} table
|
|
2165
|
-
* @param {string} newName
|
|
2166
|
-
* @returns {Promise<number>}
|
|
2167
|
-
*/
|
|
2168
1775
|
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
1776
|
loadTable(table: string): Promise<DBTable | null>;
|
|
2179
|
-
/**
|
|
2180
|
-
* @param {string[]} tables
|
|
2181
|
-
* @returns {Promise<DBTable[]>}
|
|
2182
|
-
*/
|
|
2183
1777
|
loadTables(tables: string[]): Promise<DBTable[]>;
|
|
2184
|
-
/**
|
|
2185
|
-
* @param {TableDefine | DBTable} table
|
|
2186
|
-
* @returns {Promise<void>}
|
|
2187
|
-
*/
|
|
2188
1778
|
syncTable(table: TableDefine | DBTable): Promise<void>;
|
|
2189
|
-
/**
|
|
2190
|
-
* @param {(TableDefine | DBTable)[]} tables
|
|
2191
|
-
* @returns {Promise<void>}
|
|
2192
|
-
*/
|
|
2193
1779
|
syncTables(tables: (TableDefine | DBTable)[]): Promise<void>;
|
|
1780
|
+
abort(): boolean;
|
|
1781
|
+
savepoint(): Promise<Savepoint>;
|
|
1782
|
+
[Symbol.dispose](): void;
|
|
2194
1783
|
/**
|
|
2195
1784
|
* @template T
|
|
2196
1785
|
* @overload
|
|
2197
|
-
* @param {(t: Connection) => PromiseLike<T> | T} fn
|
|
1786
|
+
* @param {Action<T> |((t: Connection, signal: AbortSignal) => PromiseLike<T> | T)} fn
|
|
2198
1787
|
* @returns {Promise<T>}
|
|
2199
1788
|
*/
|
|
2200
|
-
transaction<T>(
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
1789
|
+
transaction<T>(list: Action<T> | ((t: Connection, signal: AbortSignal) => PromiseLike<T> | T)): Promise<Awaited<T>>;
|
|
1790
|
+
transaction<T extends readonly [] | []>(list: {
|
|
1791
|
+
[P in keyof T]: Action<T[P]> | ((t: Connection, signal: AbortSignal) => PromiseLike<T[P]> | T[P]);
|
|
1792
|
+
}): Promise<{
|
|
1793
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
1794
|
+
}>;
|
|
2205
1795
|
transaction(): TransactionHandler;
|
|
2206
|
-
[
|
|
2207
|
-
#private;
|
|
1796
|
+
transaction(fn?: (Action<any> | ((t: Connection, signal: AbortSignal) => any))[] | Action<any> | ((t: Connection, signal: AbortSignal) => any)): Promise<any> | TransactionHandler;
|
|
2208
1797
|
}
|
|
2209
1798
|
|
|
2210
1799
|
/** @import { Fields } from './types' */
|
|
@@ -2234,6 +1823,7 @@ declare class Subquery {
|
|
|
2234
1823
|
|
|
2235
1824
|
type QueryOptions<T extends Fields, TB extends unknown = any> = {
|
|
2236
1825
|
table?: string | undefined;
|
|
1826
|
+
connect?: TableConnect | null | undefined;
|
|
2237
1827
|
fields: T;
|
|
2238
1828
|
pseudo?: string | undefined;
|
|
2239
1829
|
build?: ((a: object, b?: object | boolean) => TB) | null | undefined;
|
|
@@ -2243,6 +1833,7 @@ type QueryOptions<T extends Fields, TB extends unknown = any> = {
|
|
|
2243
1833
|
* @template {object} [TB=object]
|
|
2244
1834
|
* @typedef {object} QueryOptions
|
|
2245
1835
|
* @property {string} [table]
|
|
1836
|
+
* @property {TableConnect?} [connect]
|
|
2246
1837
|
* @property {T} fields
|
|
2247
1838
|
* @property {string} [pseudo]
|
|
2248
1839
|
* @property {((a: object, b?: object | boolean) => TB)?} [build]
|
|
@@ -2270,6 +1861,8 @@ declare class Query<T extends Fields, TB extends unknown = any> extends Subquery
|
|
|
2270
1861
|
constructor(options: QueryOptions<T, TB> | Query<T, TB>, noBuild?: boolean);
|
|
2271
1862
|
/** @readonly @type {string | undefined} */
|
|
2272
1863
|
readonly table: string | undefined;
|
|
1864
|
+
/** @readonly @type {TableConnect | null | undefined} */
|
|
1865
|
+
readonly connect: TableConnect | null | undefined;
|
|
2273
1866
|
/** @readonly @type {T} */
|
|
2274
1867
|
readonly fields: T;
|
|
2275
1868
|
/** @readonly @type {string} */
|