@simplysm/orm-common 14.0.99 → 14.0.101
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/dist/db-context.d.ts +0 -17
- package/dist/db-context.d.ts.map +1 -1
- package/dist/db-context.js +0 -17
- package/dist/db-context.js.map +1 -1
- package/dist/errors/db-transaction-error.d.ts +0 -15
- package/dist/errors/db-transaction-error.d.ts.map +1 -1
- package/dist/errors/db-transaction-error.js +0 -15
- package/dist/errors/db-transaction-error.js.map +1 -1
- package/dist/exec/executable.d.ts +0 -24
- package/dist/exec/executable.d.ts.map +1 -1
- package/dist/exec/executable.js +0 -24
- package/dist/exec/executable.js.map +1 -1
- package/dist/exec/queryable.d.ts +0 -300
- package/dist/exec/queryable.d.ts.map +1 -1
- package/dist/exec/queryable.js +0 -213
- package/dist/exec/queryable.js.map +1 -1
- package/dist/expr/expr.d.ts +0 -689
- package/dist/expr/expr.d.ts.map +1 -1
- package/dist/expr/expr.js +0 -689
- package/dist/expr/expr.js.map +1 -1
- package/dist/schema/factory/column-builder.d.ts +0 -86
- package/dist/schema/factory/column-builder.d.ts.map +1 -1
- package/dist/schema/factory/column-builder.js +0 -74
- package/dist/schema/factory/column-builder.js.map +1 -1
- package/dist/schema/factory/index-builder.d.ts +0 -60
- package/dist/schema/factory/index-builder.d.ts.map +1 -1
- package/dist/schema/factory/index-builder.js +0 -60
- package/dist/schema/factory/index-builder.js.map +1 -1
- package/dist/schema/factory/relation-builder.d.ts +0 -83
- package/dist/schema/factory/relation-builder.d.ts.map +1 -1
- package/dist/schema/factory/relation-builder.js +0 -77
- package/dist/schema/factory/relation-builder.js.map +1 -1
- package/dist/schema/procedure-builder.d.ts +0 -87
- package/dist/schema/procedure-builder.d.ts.map +1 -1
- package/dist/schema/procedure-builder.js +0 -87
- package/dist/schema/procedure-builder.js.map +1 -1
- package/dist/schema/table-builder.d.ts +0 -127
- package/dist/schema/table-builder.d.ts.map +1 -1
- package/dist/schema/table-builder.js +0 -127
- package/dist/schema/table-builder.js.map +1 -1
- package/dist/schema/view-builder.d.ts +0 -76
- package/dist/schema/view-builder.d.ts.map +1 -1
- package/dist/schema/view-builder.js +0 -76
- package/dist/schema/view-builder.js.map +1 -1
- package/dist/types/column.d.ts +0 -38
- package/dist/types/column.d.ts.map +1 -1
- package/dist/types/column.js +0 -13
- package/dist/types/column.js.map +1 -1
- package/dist/types/db.d.ts +0 -54
- package/dist/types/db.d.ts.map +1 -1
- package/dist/types/db.js +0 -8
- package/dist/types/db.js.map +1 -1
- package/dist/utils/result-parser.d.ts +0 -21
- package/dist/utils/result-parser.d.ts.map +1 -1
- package/dist/utils/result-parser.js +0 -24
- package/dist/utils/result-parser.js.map +1 -1
- package/package.json +2 -2
- package/src/db-context.ts +0 -17
- package/src/errors/db-transaction-error.ts +0 -15
- package/src/exec/executable.ts +0 -24
- package/src/exec/queryable.ts +0 -300
- package/src/expr/expr.ts +0 -689
- package/src/schema/factory/column-builder.ts +0 -86
- package/src/schema/factory/index-builder.ts +0 -60
- package/src/schema/factory/relation-builder.ts +0 -83
- package/src/schema/procedure-builder.ts +0 -87
- package/src/schema/table-builder.ts +0 -127
- package/src/schema/view-builder.ts +0 -76
- package/src/types/column.ts +0 -38
- package/src/types/db.ts +0 -54
- package/src/utils/result-parser.ts +0 -24
package/dist/expr/expr.d.ts
CHANGED
|
@@ -22,27 +22,6 @@ export interface SwitchExprBuilder<TPrimitive extends ColumnPrimitive> {
|
|
|
22
22
|
* SQL 문자열 대신 JSON AST(Expr)를 생성하며, QueryBuilder가
|
|
23
23
|
* 각 DBMS(MySQL, MSSQL, PostgreSQL)로 변환
|
|
24
24
|
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* // WHERE condition
|
|
28
|
-
* db.user().where((u) => [
|
|
29
|
-
* expr.eq(u.status, "active"),
|
|
30
|
-
* expr.gt(u.age, 18),
|
|
31
|
-
* ])
|
|
32
|
-
*
|
|
33
|
-
* // SELECT expression
|
|
34
|
-
* db.user().select((u) => ({
|
|
35
|
-
* name: expr.concat(u.firstName, " ", u.lastName),
|
|
36
|
-
* age: expr.dateDiff("year", u.birthDate, expr.val("DateOnly", DateOnly.today())),
|
|
37
|
-
* }))
|
|
38
|
-
*
|
|
39
|
-
* // Aggregate function
|
|
40
|
-
* db.order().groupBy((o) => o.userId).select((o) => ({
|
|
41
|
-
* userId: o.userId,
|
|
42
|
-
* total: expr.sum(o.amount),
|
|
43
|
-
* }))
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
25
|
* @see {@link Queryable} Query builder 클래스
|
|
47
26
|
* @see {@link ExprUnit} Expression 래퍼 클래스
|
|
48
27
|
*/
|
|
@@ -55,21 +34,6 @@ export declare const expr: {
|
|
|
55
34
|
* @param dataType - 값의 데이터 타입 ("string", "number", "boolean", "DateTime", "DateOnly", "Time", "Uuid", "Buffer")
|
|
56
35
|
* @param value - 래핑할 값 (undefined 허용)
|
|
57
36
|
* @returns 래핑된 ExprUnit 인스턴스
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* // String value
|
|
62
|
-
* expr.val("string", "active")
|
|
63
|
-
*
|
|
64
|
-
* // Number value
|
|
65
|
-
* expr.val("number", 100)
|
|
66
|
-
*
|
|
67
|
-
* // Date value
|
|
68
|
-
* expr.val("DateOnly", DateOnly.today())
|
|
69
|
-
*
|
|
70
|
-
* // undefined value
|
|
71
|
-
* expr.val("string", undefined)
|
|
72
|
-
* ```
|
|
73
37
|
*/
|
|
74
38
|
val<TStr extends ColumnPrimitiveStr, T extends ColumnPrimitiveMap[TStr] | undefined>(dataType: TStr, value: T): ExprUnit<T extends undefined ? ColumnPrimitiveMap[TStr] | undefined : ColumnPrimitiveMap[TStr]>;
|
|
75
39
|
/**
|
|
@@ -80,12 +44,6 @@ export declare const expr: {
|
|
|
80
44
|
* @param dataType - Column 데이터 타입
|
|
81
45
|
* @param path - Column 경로 (테이블 별칭, column 이름 등)
|
|
82
46
|
* @returns Column 참조 ExprUnit 인스턴스
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* // Direct column reference (internal use)
|
|
87
|
-
* expr.col("string", "T1", "name")
|
|
88
|
-
* ```
|
|
89
47
|
*/
|
|
90
48
|
col<TStr extends ColumnPrimitiveStr>(dataType: ColumnPrimitiveStr, ...path: string[]): ExprUnit<ColumnPrimitiveMap[TStr] | undefined>;
|
|
91
49
|
/**
|
|
@@ -96,18 +54,6 @@ export declare const expr: {
|
|
|
96
54
|
*
|
|
97
55
|
* @param dataType - 반환 값의 데이터 타입
|
|
98
56
|
* @returns 태그드 템플릿 함수
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```typescript
|
|
102
|
-
* // Using MySQL JSON function
|
|
103
|
-
* db.user().select((u) => ({
|
|
104
|
-
* name: u.name,
|
|
105
|
-
* data: expr.raw("string")`JSON_EXTRACT(${u.metadata}, '$.email')`,
|
|
106
|
-
* }))
|
|
107
|
-
*
|
|
108
|
-
* // PostgreSQL array function
|
|
109
|
-
* expr.raw("number")`ARRAY_LENGTH(${u.tags}, 1)`
|
|
110
|
-
* ```
|
|
111
57
|
*/
|
|
112
58
|
raw<T extends ColumnPrimitiveStr>(dataType: T): (strings: TemplateStringsArray, ...values: ExprInput<ColumnPrimitive>[]) => ExprUnit<ColumnPrimitiveMap[T] | undefined>;
|
|
113
59
|
/**
|
|
@@ -118,12 +64,6 @@ export declare const expr: {
|
|
|
118
64
|
* @param source - 비교할 column 또는 expression
|
|
119
65
|
* @param target - 비교 대상 값 또는 expression
|
|
120
66
|
* @returns WHERE 조건 expression
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* db.user().where((u) => [expr.eq(u.status, "active")])
|
|
125
|
-
* // WHERE status <=> 'active' (MySQL)
|
|
126
|
-
* ```
|
|
127
67
|
*/
|
|
128
68
|
eq<T extends ColumnPrimitive>(source: ExprUnit<T>, target: ExprInput<T>): WhereExprUnit;
|
|
129
69
|
/**
|
|
@@ -132,12 +72,6 @@ export declare const expr: {
|
|
|
132
72
|
* @param source - 비교할 column 또는 expression
|
|
133
73
|
* @param target - 비교 대상 값 또는 expression
|
|
134
74
|
* @returns WHERE 조건 expression
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```typescript
|
|
138
|
-
* db.user().where((u) => [expr.gt(u.age, 18)])
|
|
139
|
-
* // WHERE age > 18
|
|
140
|
-
* ```
|
|
141
75
|
*/
|
|
142
76
|
gt<T extends ColumnPrimitive>(source: ExprUnit<T>, target: ExprInput<T>): WhereExprUnit;
|
|
143
77
|
/**
|
|
@@ -146,12 +80,6 @@ export declare const expr: {
|
|
|
146
80
|
* @param source - 비교할 column 또는 expression
|
|
147
81
|
* @param target - 비교 대상 값 또는 expression
|
|
148
82
|
* @returns WHERE 조건 expression
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* db.user().where((u) => [expr.lt(u.score, 60)])
|
|
153
|
-
* // WHERE score < 60
|
|
154
|
-
* ```
|
|
155
83
|
*/
|
|
156
84
|
lt<T extends ColumnPrimitive>(source: ExprUnit<T>, target: ExprInput<T>): WhereExprUnit;
|
|
157
85
|
/**
|
|
@@ -160,12 +88,6 @@ export declare const expr: {
|
|
|
160
88
|
* @param source - 비교할 column 또는 expression
|
|
161
89
|
* @param target - 비교 대상 값 또는 expression
|
|
162
90
|
* @returns WHERE 조건 expression
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```typescript
|
|
166
|
-
* db.user().where((u) => [expr.gte(u.age, 18)])
|
|
167
|
-
* // WHERE age >= 18
|
|
168
|
-
* ```
|
|
169
91
|
*/
|
|
170
92
|
gte<T extends ColumnPrimitive>(source: ExprUnit<T>, target: ExprInput<T>): WhereExprUnit;
|
|
171
93
|
/**
|
|
@@ -174,12 +96,6 @@ export declare const expr: {
|
|
|
174
96
|
* @param source - 비교할 column 또는 expression
|
|
175
97
|
* @param target - 비교 대상 값 또는 expression
|
|
176
98
|
* @returns WHERE 조건 expression
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
* ```typescript
|
|
180
|
-
* db.user().where((u) => [expr.lte(u.score, 100)])
|
|
181
|
-
* // WHERE score <= 100
|
|
182
|
-
* ```
|
|
183
99
|
*/
|
|
184
100
|
lte<T extends ColumnPrimitive>(source: ExprUnit<T>, target: ExprInput<T>): WhereExprUnit;
|
|
185
101
|
/**
|
|
@@ -191,17 +107,6 @@ export declare const expr: {
|
|
|
191
107
|
* @param from - 시작 값 (undefined이면 하한 없음)
|
|
192
108
|
* @param to - 끝 값 (undefined이면 상한 없음)
|
|
193
109
|
* @returns WHERE 조건 expression
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* ```typescript
|
|
197
|
-
* // Specify range
|
|
198
|
-
* db.user().where((u) => [expr.between(u.age, 18, 65)])
|
|
199
|
-
* // WHERE age BETWEEN 18 AND 65
|
|
200
|
-
*
|
|
201
|
-
* // Specify only lower bound
|
|
202
|
-
* db.user().where((u) => [expr.between(u.age, 18, undefined)])
|
|
203
|
-
* // WHERE age >= 18
|
|
204
|
-
* ```
|
|
205
110
|
*/
|
|
206
111
|
between<T extends ColumnPrimitive>(source: ExprUnit<T>, from?: ExprInput<T>, to?: ExprInput<T>): WhereExprUnit;
|
|
207
112
|
/**
|
|
@@ -209,12 +114,6 @@ export declare const expr: {
|
|
|
209
114
|
*
|
|
210
115
|
* @param source - Column or expression to check
|
|
211
116
|
* @returns WHERE condition expression
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* db.user().where((u) => [expr.null(u.deletedAt)])
|
|
216
|
-
* // WHERE deletedAt IS NULL
|
|
217
|
-
* ```
|
|
218
117
|
*/
|
|
219
118
|
null<T extends ColumnPrimitive>(source: ExprUnit<T>): WhereExprUnit;
|
|
220
119
|
/**
|
|
@@ -226,16 +125,6 @@ export declare const expr: {
|
|
|
226
125
|
* @param source - Column or expression to search
|
|
227
126
|
* @param pattern - Search pattern (%, _ wildcards available)
|
|
228
127
|
* @returns WHERE condition expression
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```typescript
|
|
232
|
-
* // Prefix search
|
|
233
|
-
* db.user().where((u) => [expr.like(u.name, "John%")])
|
|
234
|
-
* // WHERE name LIKE 'John%' ESCAPE '\'
|
|
235
|
-
*
|
|
236
|
-
* // Contains search
|
|
237
|
-
* db.user().where((u) => [expr.like(u.email, "%@gmail.com")])
|
|
238
|
-
* ```
|
|
239
128
|
*/
|
|
240
129
|
like(source: ExprUnit<string | undefined>, pattern: ExprInput<string | undefined>): WhereExprUnit;
|
|
241
130
|
/**
|
|
@@ -246,12 +135,6 @@ export declare const expr: {
|
|
|
246
135
|
* @param source - Column or expression to search
|
|
247
136
|
* @param pattern - Regular expression pattern
|
|
248
137
|
* @returns WHERE condition expression
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```typescript
|
|
252
|
-
* db.user().where((u) => [expr.regexp(u.email, "^[a-z]+@")])
|
|
253
|
-
* // MySQL: WHERE email REGEXP '^[a-z]+@'
|
|
254
|
-
* ```
|
|
255
138
|
*/
|
|
256
139
|
regexp(source: ExprUnit<string | undefined>, pattern: ExprInput<string | undefined>): WhereExprUnit;
|
|
257
140
|
/**
|
|
@@ -260,12 +143,6 @@ export declare const expr: {
|
|
|
260
143
|
* @param source - Column or expression to compare
|
|
261
144
|
* @param values - List of values to compare against
|
|
262
145
|
* @returns WHERE condition expression
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* ```typescript
|
|
266
|
-
* db.user().where((u) => [expr.in(u.status, ["active", "pending"])])
|
|
267
|
-
* // WHERE status IN ('active', 'pending')
|
|
268
|
-
* ```
|
|
269
146
|
*/
|
|
270
147
|
in<T extends ColumnPrimitive>(source: ExprUnit<T>, values: ExprInput<T>[]): WhereExprUnit;
|
|
271
148
|
/**
|
|
@@ -277,19 +154,6 @@ export declare const expr: {
|
|
|
277
154
|
* @param query - Queryable that returns a single column
|
|
278
155
|
* @returns WHERE condition expression
|
|
279
156
|
* @throws {Error} When the subquery does not return a single column
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```typescript
|
|
283
|
-
* db.user().where((u) => [
|
|
284
|
-
* expr.inQuery(
|
|
285
|
-
* u.id,
|
|
286
|
-
* db.order()
|
|
287
|
-
* .where((o) => [expr.gt(o.amount, 1000)])
|
|
288
|
-
* .select((o) => ({ userId: o.userId }))
|
|
289
|
-
* ),
|
|
290
|
-
* ])
|
|
291
|
-
* // WHERE id IN (SELECT userId FROM Order WHERE amount > 1000)
|
|
292
|
-
* ```
|
|
293
157
|
*/
|
|
294
158
|
inQuery<T extends ColumnPrimitive, TData extends Record<string, T>>(source: ExprUnit<T>, query: Queryable<TData, any>): WhereExprUnit;
|
|
295
159
|
/**
|
|
@@ -299,17 +163,6 @@ export declare const expr: {
|
|
|
299
163
|
*
|
|
300
164
|
* @param query - Queryable to check for existence
|
|
301
165
|
* @returns WHERE condition expression
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
* ```typescript
|
|
305
|
-
* // Query users who have orders
|
|
306
|
-
* db.user().where((u) => [
|
|
307
|
-
* expr.exists(
|
|
308
|
-
* db.order().where((o) => [expr.eq(o.userId, u.id)])
|
|
309
|
-
* ),
|
|
310
|
-
* ])
|
|
311
|
-
* // WHERE EXISTS (SELECT 1 FROM Order WHERE userId = User.id)
|
|
312
|
-
* ```
|
|
313
166
|
*/
|
|
314
167
|
exists(query: Queryable<any, any>): WhereExprUnit;
|
|
315
168
|
/**
|
|
@@ -317,12 +170,6 @@ export declare const expr: {
|
|
|
317
170
|
*
|
|
318
171
|
* @param arg - Condition to negate
|
|
319
172
|
* @returns Negated WHERE condition expression
|
|
320
|
-
*
|
|
321
|
-
* @example
|
|
322
|
-
* ```typescript
|
|
323
|
-
* db.user().where((u) => [expr.not(expr.eq(u.status, "deleted"))])
|
|
324
|
-
* // WHERE NOT (status <=> 'deleted')
|
|
325
|
-
* ```
|
|
326
173
|
*/
|
|
327
174
|
not(arg: WhereExprUnit): WhereExprUnit;
|
|
328
175
|
/**
|
|
@@ -332,17 +179,6 @@ export declare const expr: {
|
|
|
332
179
|
*
|
|
333
180
|
* @param conditions - List of conditions to combine with AND
|
|
334
181
|
* @returns Combined WHERE condition expression
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```typescript
|
|
338
|
-
* db.user().where((u) => [
|
|
339
|
-
* expr.and([
|
|
340
|
-
* expr.eq(u.status, "active"),
|
|
341
|
-
* expr.gte(u.age, 18),
|
|
342
|
-
* ]),
|
|
343
|
-
* ])
|
|
344
|
-
* // WHERE (status <=> 'active' AND age >= 18)
|
|
345
|
-
* ```
|
|
346
182
|
*/
|
|
347
183
|
and(conditions: WhereExprUnit[]): WhereExprUnit;
|
|
348
184
|
/**
|
|
@@ -350,17 +186,6 @@ export declare const expr: {
|
|
|
350
186
|
*
|
|
351
187
|
* @param conditions - List of conditions to combine with OR
|
|
352
188
|
* @returns Combined WHERE condition expression
|
|
353
|
-
*
|
|
354
|
-
* @example
|
|
355
|
-
* ```typescript
|
|
356
|
-
* db.user().where((u) => [
|
|
357
|
-
* expr.or([
|
|
358
|
-
* expr.eq(u.status, "active"),
|
|
359
|
-
* expr.eq(u.status, "pending"),
|
|
360
|
-
* ]),
|
|
361
|
-
* ])
|
|
362
|
-
* // WHERE (status <=> 'active' OR status <=> 'pending')
|
|
363
|
-
* ```
|
|
364
189
|
*/
|
|
365
190
|
or(conditions: WhereExprUnit[]): WhereExprUnit;
|
|
366
191
|
/**
|
|
@@ -370,14 +195,6 @@ export declare const expr: {
|
|
|
370
195
|
*
|
|
371
196
|
* @param args - Strings to concatenate
|
|
372
197
|
* @returns Concatenated string expression
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* ```typescript
|
|
376
|
-
* db.user().select((u) => ({
|
|
377
|
-
* fullName: expr.concat(u.firstName, " ", u.lastName),
|
|
378
|
-
* }))
|
|
379
|
-
* // SELECT CONCAT(firstName, ' ', lastName) AS fullName
|
|
380
|
-
* ```
|
|
381
198
|
*/
|
|
382
199
|
concat(...args: ExprInput<string | undefined>[]): ExprUnit<string>;
|
|
383
200
|
/**
|
|
@@ -386,14 +203,6 @@ export declare const expr: {
|
|
|
386
203
|
* @param source - Original string
|
|
387
204
|
* @param length - Number of characters to extract
|
|
388
205
|
* @returns Extracted string expression
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* ```typescript
|
|
392
|
-
* db.user().select((u) => ({
|
|
393
|
-
* initial: expr.left(u.name, 1),
|
|
394
|
-
* }))
|
|
395
|
-
* // SELECT LEFT(name, 1) AS initial
|
|
396
|
-
* ```
|
|
397
206
|
*/
|
|
398
207
|
left<T extends string | undefined>(source: ExprUnit<T>, length: ExprInput<number>): ExprUnit<T>;
|
|
399
208
|
/**
|
|
@@ -402,14 +211,6 @@ export declare const expr: {
|
|
|
402
211
|
* @param source - Original string
|
|
403
212
|
* @param length - Number of characters to extract
|
|
404
213
|
* @returns Extracted string expression
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* ```typescript
|
|
408
|
-
* db.phone().select((p) => ({
|
|
409
|
-
* lastFour: expr.right(p.number, 4),
|
|
410
|
-
* }))
|
|
411
|
-
* // SELECT RIGHT(number, 4) AS lastFour
|
|
412
|
-
* ```
|
|
413
214
|
*/
|
|
414
215
|
right<T extends string | undefined>(source: ExprUnit<T>, length: ExprInput<number>): ExprUnit<T>;
|
|
415
216
|
/**
|
|
@@ -417,14 +218,6 @@ export declare const expr: {
|
|
|
417
218
|
*
|
|
418
219
|
* @param source - Original string
|
|
419
220
|
* @returns String expression with whitespace removed
|
|
420
|
-
*
|
|
421
|
-
* @example
|
|
422
|
-
* ```typescript
|
|
423
|
-
* db.user().select((u) => ({
|
|
424
|
-
* name: expr.trim(u.name),
|
|
425
|
-
* }))
|
|
426
|
-
* // SELECT TRIM(name) AS name
|
|
427
|
-
* ```
|
|
428
221
|
*/
|
|
429
222
|
trim<T extends string | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
430
223
|
/**
|
|
@@ -436,15 +229,6 @@ export declare const expr: {
|
|
|
436
229
|
* @param length - Target length
|
|
437
230
|
* @param fillString - String to use for padding
|
|
438
231
|
* @returns Padded string expression
|
|
439
|
-
*
|
|
440
|
-
* @example
|
|
441
|
-
* ```typescript
|
|
442
|
-
* db.order().select((o) => ({
|
|
443
|
-
* orderNo: expr.padStart(expr.cast(o.id, { type: "varchar", length: 10 }), 8, "0"),
|
|
444
|
-
* }))
|
|
445
|
-
* // SELECT LPAD(CAST(id AS VARCHAR(10)), 8, '0') AS orderNo
|
|
446
|
-
* // Result: "00000123"
|
|
447
|
-
* ```
|
|
448
232
|
*/
|
|
449
233
|
padStart<T extends string | undefined>(source: ExprUnit<T>, length: ExprInput<number>, fillString: ExprInput<string>): ExprUnit<T>;
|
|
450
234
|
/**
|
|
@@ -454,14 +238,6 @@ export declare const expr: {
|
|
|
454
238
|
* @param from - String to find
|
|
455
239
|
* @param to - Replacement string
|
|
456
240
|
* @returns Replaced string expression
|
|
457
|
-
*
|
|
458
|
-
* @example
|
|
459
|
-
* ```typescript
|
|
460
|
-
* db.user().select((u) => ({
|
|
461
|
-
* phone: expr.replace(u.phone, "-", ""),
|
|
462
|
-
* }))
|
|
463
|
-
* // SELECT REPLACE(phone, '-', '') AS phone
|
|
464
|
-
* ```
|
|
465
241
|
*/
|
|
466
242
|
replace<T extends string | undefined>(source: ExprUnit<T>, from: ExprInput<string>, to: ExprInput<string>): ExprUnit<T>;
|
|
467
243
|
/**
|
|
@@ -469,14 +245,6 @@ export declare const expr: {
|
|
|
469
245
|
*
|
|
470
246
|
* @param source - Original string
|
|
471
247
|
* @returns Uppercase string expression
|
|
472
|
-
*
|
|
473
|
-
* @example
|
|
474
|
-
* ```typescript
|
|
475
|
-
* db.user().select((u) => ({
|
|
476
|
-
* code: expr.upper(u.code),
|
|
477
|
-
* }))
|
|
478
|
-
* // SELECT UPPER(code) AS code
|
|
479
|
-
* ```
|
|
480
248
|
*/
|
|
481
249
|
upper<T extends string | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
482
250
|
/**
|
|
@@ -484,14 +252,6 @@ export declare const expr: {
|
|
|
484
252
|
*
|
|
485
253
|
* @param source - Original string
|
|
486
254
|
* @returns Lowercase string expression
|
|
487
|
-
*
|
|
488
|
-
* @example
|
|
489
|
-
* ```typescript
|
|
490
|
-
* db.user().select((u) => ({
|
|
491
|
-
* email: expr.lower(u.email),
|
|
492
|
-
* }))
|
|
493
|
-
* // SELECT LOWER(email) AS email
|
|
494
|
-
* ```
|
|
495
255
|
*/
|
|
496
256
|
lower<T extends string | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
497
257
|
/**
|
|
@@ -499,14 +259,6 @@ export declare const expr: {
|
|
|
499
259
|
*
|
|
500
260
|
* @param source - Original string
|
|
501
261
|
* @returns Character count
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* ```typescript
|
|
505
|
-
* db.user().select((u) => ({
|
|
506
|
-
* nameLength: expr.length(u.name),
|
|
507
|
-
* }))
|
|
508
|
-
* // SELECT CHAR_LENGTH(name) AS nameLength
|
|
509
|
-
* ```
|
|
510
262
|
*/
|
|
511
263
|
length(source: ExprUnit<string | undefined>): ExprUnit<number>;
|
|
512
264
|
/**
|
|
@@ -516,14 +268,6 @@ export declare const expr: {
|
|
|
516
268
|
*
|
|
517
269
|
* @param source - Original string
|
|
518
270
|
* @returns Byte count
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* ```typescript
|
|
522
|
-
* db.user().select((u) => ({
|
|
523
|
-
* byteLen: expr.byteLength(u.name),
|
|
524
|
-
* }))
|
|
525
|
-
* // SELECT OCTET_LENGTH(name) AS byteLen
|
|
526
|
-
* ```
|
|
527
271
|
*/
|
|
528
272
|
byteLength(source: ExprUnit<string | undefined>): ExprUnit<number>;
|
|
529
273
|
/**
|
|
@@ -535,15 +279,6 @@ export declare const expr: {
|
|
|
535
279
|
* @param start - Start position (starting from 1)
|
|
536
280
|
* @param length - Length to extract (to the end if omitted)
|
|
537
281
|
* @returns Extracted string expression
|
|
538
|
-
*
|
|
539
|
-
* @example
|
|
540
|
-
* ```typescript
|
|
541
|
-
* db.user().select((u) => ({
|
|
542
|
-
* // From "Hello World", 5 characters starting at index 1: "Hello"
|
|
543
|
-
* prefix: expr.substring(u.name, 1, 5),
|
|
544
|
-
* }))
|
|
545
|
-
* // SELECT SUBSTRING(name, 1, 5) AS prefix
|
|
546
|
-
* ```
|
|
547
282
|
*/
|
|
548
283
|
substring<T extends string | undefined>(source: ExprUnit<T>, start: ExprInput<number>, length?: ExprInput<number>): ExprUnit<T>;
|
|
549
284
|
/**
|
|
@@ -554,15 +289,6 @@ export declare const expr: {
|
|
|
554
289
|
* @param source - String to search in
|
|
555
290
|
* @param search - String to find
|
|
556
291
|
* @returns Position (starting from 1, 0 if not found)
|
|
557
|
-
*
|
|
558
|
-
* @example
|
|
559
|
-
* ```typescript
|
|
560
|
-
* db.user().select((u) => ({
|
|
561
|
-
* atPos: expr.indexOf(u.email, "@"),
|
|
562
|
-
* }))
|
|
563
|
-
* // SELECT LOCATE('@', email) AS atPos (MySQL)
|
|
564
|
-
* // "john@example.com" → 5
|
|
565
|
-
* ```
|
|
566
292
|
*/
|
|
567
293
|
indexOf(source: ExprUnit<string | undefined>, search: ExprInput<string>): ExprUnit<number>;
|
|
568
294
|
/**
|
|
@@ -570,14 +296,6 @@ export declare const expr: {
|
|
|
570
296
|
*
|
|
571
297
|
* @param source - Original number
|
|
572
298
|
* @returns Absolute value expression
|
|
573
|
-
*
|
|
574
|
-
* @example
|
|
575
|
-
* ```typescript
|
|
576
|
-
* db.account().select((a) => ({
|
|
577
|
-
* balance: expr.abs(a.balance),
|
|
578
|
-
* }))
|
|
579
|
-
* // SELECT ABS(balance) AS balance
|
|
580
|
-
* ```
|
|
581
299
|
*/
|
|
582
300
|
abs<T extends number | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
583
301
|
/**
|
|
@@ -586,15 +304,6 @@ export declare const expr: {
|
|
|
586
304
|
* @param source - Original number
|
|
587
305
|
* @param digits - Number of decimal places
|
|
588
306
|
* @returns Rounded number expression
|
|
589
|
-
*
|
|
590
|
-
* @example
|
|
591
|
-
* ```typescript
|
|
592
|
-
* db.product().select((p) => ({
|
|
593
|
-
* price: expr.round(p.price, 2),
|
|
594
|
-
* }))
|
|
595
|
-
* // SELECT ROUND(price, 2) AS price
|
|
596
|
-
* // 123.456 → 123.46
|
|
597
|
-
* ```
|
|
598
307
|
*/
|
|
599
308
|
round<T extends number | undefined>(source: ExprUnit<T>, digits: number): ExprUnit<T>;
|
|
600
309
|
/**
|
|
@@ -602,15 +311,6 @@ export declare const expr: {
|
|
|
602
311
|
*
|
|
603
312
|
* @param source - Original number
|
|
604
313
|
* @returns Ceiling number expression
|
|
605
|
-
*
|
|
606
|
-
* @example
|
|
607
|
-
* ```typescript
|
|
608
|
-
* db.order().select((o) => ({
|
|
609
|
-
* pages: expr.ceil(expr.multiply(o.itemCount, 0.1)),
|
|
610
|
-
* }))
|
|
611
|
-
* // SELECT CEILING(itemCount / 10) AS pages
|
|
612
|
-
* // 25 / 10 = 2.5 → 3
|
|
613
|
-
* ```
|
|
614
314
|
*/
|
|
615
315
|
ceil<T extends number | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
616
316
|
/**
|
|
@@ -618,15 +318,6 @@ export declare const expr: {
|
|
|
618
318
|
*
|
|
619
319
|
* @param source - Original number
|
|
620
320
|
* @returns Floor number expression
|
|
621
|
-
*
|
|
622
|
-
* @example
|
|
623
|
-
* ```typescript
|
|
624
|
-
* db.user().select((u) => ({
|
|
625
|
-
* ageGroup: expr.floor(expr.multiply(u.age, 0.1)),
|
|
626
|
-
* }))
|
|
627
|
-
* // SELECT FLOOR(age / 10) AS ageGroup
|
|
628
|
-
* // 25 / 10 = 2.5 → 2
|
|
629
|
-
* ```
|
|
630
321
|
*/
|
|
631
322
|
floor<T extends number | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
632
323
|
/**
|
|
@@ -634,14 +325,6 @@ export declare const expr: {
|
|
|
634
325
|
*
|
|
635
326
|
* @param source - DateTime or DateOnly expression
|
|
636
327
|
* @returns Year (4-digit number)
|
|
637
|
-
*
|
|
638
|
-
* @example
|
|
639
|
-
* ```typescript
|
|
640
|
-
* db.user().select((u) => ({
|
|
641
|
-
* birthYear: expr.year(u.birthDate),
|
|
642
|
-
* }))
|
|
643
|
-
* // SELECT YEAR(birthDate) AS birthYear
|
|
644
|
-
* ```
|
|
645
328
|
*/
|
|
646
329
|
year<T extends DateTime | DateOnly | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
647
330
|
/**
|
|
@@ -649,14 +332,6 @@ export declare const expr: {
|
|
|
649
332
|
*
|
|
650
333
|
* @param source - DateTime or DateOnly expression
|
|
651
334
|
* @returns Month (1~12)
|
|
652
|
-
*
|
|
653
|
-
* @example
|
|
654
|
-
* ```typescript
|
|
655
|
-
* db.order().select((o) => ({
|
|
656
|
-
* orderMonth: expr.month(o.createdAt),
|
|
657
|
-
* }))
|
|
658
|
-
* // SELECT MONTH(createdAt) AS orderMonth
|
|
659
|
-
* ```
|
|
660
335
|
*/
|
|
661
336
|
month<T extends DateTime | DateOnly | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
662
337
|
/**
|
|
@@ -664,14 +339,6 @@ export declare const expr: {
|
|
|
664
339
|
*
|
|
665
340
|
* @param source - DateTime or DateOnly expression
|
|
666
341
|
* @returns Day (1~31)
|
|
667
|
-
*
|
|
668
|
-
* @example
|
|
669
|
-
* ```typescript
|
|
670
|
-
* db.user().select((u) => ({
|
|
671
|
-
* birthDay: expr.day(u.birthDate),
|
|
672
|
-
* }))
|
|
673
|
-
* // SELECT DAY(birthDate) AS birthDay
|
|
674
|
-
* ```
|
|
675
342
|
*/
|
|
676
343
|
day<T extends DateTime | DateOnly | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
677
344
|
/**
|
|
@@ -679,14 +346,6 @@ export declare const expr: {
|
|
|
679
346
|
*
|
|
680
347
|
* @param source - DateTime or Time expression
|
|
681
348
|
* @returns Hour (0~23)
|
|
682
|
-
*
|
|
683
|
-
* @example
|
|
684
|
-
* ```typescript
|
|
685
|
-
* db.log().select((l) => ({
|
|
686
|
-
* logHour: expr.hour(l.createdAt),
|
|
687
|
-
* }))
|
|
688
|
-
* // SELECT HOUR(createdAt) AS logHour
|
|
689
|
-
* ```
|
|
690
349
|
*/
|
|
691
350
|
hour<T extends DateTime | Time | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
692
351
|
/**
|
|
@@ -694,14 +353,6 @@ export declare const expr: {
|
|
|
694
353
|
*
|
|
695
354
|
* @param source - DateTime or Time expression
|
|
696
355
|
* @returns Minute (0~59)
|
|
697
|
-
*
|
|
698
|
-
* @example
|
|
699
|
-
* ```typescript
|
|
700
|
-
* db.log().select((l) => ({
|
|
701
|
-
* logMinute: expr.minute(l.createdAt),
|
|
702
|
-
* }))
|
|
703
|
-
* // SELECT MINUTE(createdAt) AS logMinute
|
|
704
|
-
* ```
|
|
705
356
|
*/
|
|
706
357
|
minute<T extends DateTime | Time | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
707
358
|
/**
|
|
@@ -709,14 +360,6 @@ export declare const expr: {
|
|
|
709
360
|
*
|
|
710
361
|
* @param source - DateTime or Time expression
|
|
711
362
|
* @returns Second (0~59)
|
|
712
|
-
*
|
|
713
|
-
* @example
|
|
714
|
-
* ```typescript
|
|
715
|
-
* db.log().select((l) => ({
|
|
716
|
-
* logSecond: expr.second(l.createdAt),
|
|
717
|
-
* }))
|
|
718
|
-
* // SELECT SECOND(createdAt) AS logSecond
|
|
719
|
-
* ```
|
|
720
363
|
*/
|
|
721
364
|
second<T extends DateTime | Time | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
722
365
|
/**
|
|
@@ -726,14 +369,6 @@ export declare const expr: {
|
|
|
726
369
|
*
|
|
727
370
|
* @param source - DateOnly expression
|
|
728
371
|
* @returns ISO week number
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```typescript
|
|
732
|
-
* db.order().select((o) => ({
|
|
733
|
-
* weekNum: expr.isoWeek(o.orderDate),
|
|
734
|
-
* }))
|
|
735
|
-
* // SELECT WEEK(orderDate, 3) AS weekNum (MySQL)
|
|
736
|
-
* ```
|
|
737
372
|
*/
|
|
738
373
|
isoWeek<T extends DateOnly | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
739
374
|
/**
|
|
@@ -743,14 +378,6 @@ export declare const expr: {
|
|
|
743
378
|
*
|
|
744
379
|
* @param source - DateOnly expression
|
|
745
380
|
* @returns Week start date (Monday)
|
|
746
|
-
*
|
|
747
|
-
* @example
|
|
748
|
-
* ```typescript
|
|
749
|
-
* db.order().select((o) => ({
|
|
750
|
-
* weekStart: expr.isoWeekStartDate(o.orderDate),
|
|
751
|
-
* }))
|
|
752
|
-
* // 2024-01-10 (Wed) → 2024-01-08 (Mon)
|
|
753
|
-
* ```
|
|
754
381
|
*/
|
|
755
382
|
isoWeekStartDate<T extends DateOnly | undefined>(source: ExprUnit<T>): ExprUnit<T>;
|
|
756
383
|
/**
|
|
@@ -760,14 +387,6 @@ export declare const expr: {
|
|
|
760
387
|
*
|
|
761
388
|
* @param source - DateOnly expression
|
|
762
389
|
* @returns Year-month string (YYYYMM)
|
|
763
|
-
*
|
|
764
|
-
* @example
|
|
765
|
-
* ```typescript
|
|
766
|
-
* db.order().select((o) => ({
|
|
767
|
-
* yearMonth: expr.isoYearMonth(o.orderDate),
|
|
768
|
-
* }))
|
|
769
|
-
* // 2024-01-15 → "202401"
|
|
770
|
-
* ```
|
|
771
390
|
*/
|
|
772
391
|
isoYearMonth<T extends DateOnly | undefined>(source: ExprUnit<T>): ExprUnit<T extends undefined ? undefined : string>;
|
|
773
392
|
/**
|
|
@@ -777,14 +396,6 @@ export declare const expr: {
|
|
|
777
396
|
* @param from - Start date
|
|
778
397
|
* @param to - End date
|
|
779
398
|
* @returns Difference value (to - from)
|
|
780
|
-
*
|
|
781
|
-
* @example
|
|
782
|
-
* ```typescript
|
|
783
|
-
* db.user().select((u) => ({
|
|
784
|
-
* age: expr.dateDiff("year", u.birthDate, expr.val("DateOnly", DateOnly.today())),
|
|
785
|
-
* }))
|
|
786
|
-
* // SELECT DATEDIFF(year, birthDate, '2024-01-15') AS age
|
|
787
|
-
* ```
|
|
788
399
|
*/
|
|
789
400
|
dateDiff<T extends DateTime | DateOnly | Time | undefined>(unit: DateUnit, from: ExprInput<T>, to: ExprInput<T>): ExprUnit<T extends undefined ? undefined : number>;
|
|
790
401
|
/**
|
|
@@ -794,14 +405,6 @@ export declare const expr: {
|
|
|
794
405
|
* @param source - Original date
|
|
795
406
|
* @param value - Value to add (negative allowed)
|
|
796
407
|
* @returns Calculated date
|
|
797
|
-
*
|
|
798
|
-
* @example
|
|
799
|
-
* ```typescript
|
|
800
|
-
* db.subscription().select((s) => ({
|
|
801
|
-
* expiresAt: expr.dateAdd("month", s.startDate, 12),
|
|
802
|
-
* }))
|
|
803
|
-
* // SELECT DATEADD(month, 12, startDate) AS expiresAt
|
|
804
|
-
* ```
|
|
805
408
|
*/
|
|
806
409
|
dateAdd<T extends DateTime | DateOnly | Time | undefined>(unit: DateUnit, source: ExprUnit<T>, value: ExprInput<number>): ExprUnit<T>;
|
|
807
410
|
/**
|
|
@@ -812,15 +415,6 @@ export declare const expr: {
|
|
|
812
415
|
* @param source - Date expression
|
|
813
416
|
* @param format - Format string (e.g., "%Y-%m-%d")
|
|
814
417
|
* @returns Formatted string expression
|
|
815
|
-
*
|
|
816
|
-
* @example
|
|
817
|
-
* ```typescript
|
|
818
|
-
* db.order().select((o) => ({
|
|
819
|
-
* orderDate: expr.formatDate(o.createdAt, "%Y-%m-%d"),
|
|
820
|
-
* }))
|
|
821
|
-
* // SELECT DATE_FORMAT(createdAt, '%Y-%m-%d') AS orderDate (MySQL)
|
|
822
|
-
* // 2024-01-15 10:30:00 → "2024-01-15"
|
|
823
|
-
* ```
|
|
824
418
|
*/
|
|
825
419
|
formatDate<T extends DateTime | DateOnly | Time | undefined>(source: ExprUnit<T>, format: string): ExprUnit<T extends undefined ? undefined : string>;
|
|
826
420
|
/**
|
|
@@ -830,14 +424,6 @@ export declare const expr: {
|
|
|
830
424
|
*
|
|
831
425
|
* @param args - Values to inspect (last is default value)
|
|
832
426
|
* @returns First non-null value
|
|
833
|
-
*
|
|
834
|
-
* @example
|
|
835
|
-
* ```typescript
|
|
836
|
-
* db.user().select((u) => ({
|
|
837
|
-
* displayName: expr.coalesce(u.nickname, u.name, "Guest"),
|
|
838
|
-
* }))
|
|
839
|
-
* // SELECT COALESCE(nickname, name, 'Guest') AS displayName
|
|
840
|
-
* ```
|
|
841
427
|
*/
|
|
842
428
|
coalesce: typeof coalesce;
|
|
843
429
|
/**
|
|
@@ -848,15 +434,6 @@ export declare const expr: {
|
|
|
848
434
|
* @param source - Original value
|
|
849
435
|
* @param value - Value to compare
|
|
850
436
|
* @returns NULL or original value
|
|
851
|
-
*
|
|
852
|
-
* @example
|
|
853
|
-
* ```typescript
|
|
854
|
-
* db.user().select((u) => ({
|
|
855
|
-
* // Convert empty string to NULL
|
|
856
|
-
* bio: expr.nullIf(u.bio, ""),
|
|
857
|
-
* }))
|
|
858
|
-
* // SELECT NULLIF(bio, '') AS bio
|
|
859
|
-
* ```
|
|
860
437
|
*/
|
|
861
438
|
nullIf<T extends ColumnPrimitive>(source: ExprUnit<T>, value: ExprInput<T>): ExprUnit<T | undefined>;
|
|
862
439
|
/**
|
|
@@ -866,14 +443,6 @@ export declare const expr: {
|
|
|
866
443
|
*
|
|
867
444
|
* @param condition - Condition to transform
|
|
868
445
|
* @returns boolean expression
|
|
869
|
-
*
|
|
870
|
-
* @example
|
|
871
|
-
* ```typescript
|
|
872
|
-
* db.user().select((u) => ({
|
|
873
|
-
* isActive: expr.is(expr.eq(u.status, "active")),
|
|
874
|
-
* }))
|
|
875
|
-
* // SELECT (status <=> 'active') AS isActive
|
|
876
|
-
* ```
|
|
877
446
|
*/
|
|
878
447
|
is(condition: WhereExprUnit): ExprUnit<boolean>;
|
|
879
448
|
/**
|
|
@@ -882,18 +451,6 @@ export declare const expr: {
|
|
|
882
451
|
* 메서드 체이닝으로 조건 분기 구성
|
|
883
452
|
*
|
|
884
453
|
* @returns SwitchExprBuilder instance
|
|
885
|
-
*
|
|
886
|
-
* @example
|
|
887
|
-
* ```typescript
|
|
888
|
-
* db.user().select((u) => ({
|
|
889
|
-
* grade: expr.switch<string>()
|
|
890
|
-
* .case(expr.gte(u.score, 90), "A")
|
|
891
|
-
* .case(expr.gte(u.score, 80), "B")
|
|
892
|
-
* .case(expr.gte(u.score, 70), "C")
|
|
893
|
-
* .default("F"),
|
|
894
|
-
* }))
|
|
895
|
-
* // SELECT CASE WHEN score >= 90 THEN 'A' ... ELSE 'F' END AS grade
|
|
896
|
-
* ```
|
|
897
454
|
*/
|
|
898
455
|
switch<T extends ColumnPrimitive>(): SwitchExprBuilder<T>;
|
|
899
456
|
/**
|
|
@@ -903,14 +460,6 @@ export declare const expr: {
|
|
|
903
460
|
* @param then - Value when condition is true
|
|
904
461
|
* @param else_ - Value when condition is false
|
|
905
462
|
* @returns Conditional value expression
|
|
906
|
-
*
|
|
907
|
-
* @example
|
|
908
|
-
* ```typescript
|
|
909
|
-
* db.user().select((u) => ({
|
|
910
|
-
* type: expr.if(expr.gte(u.age, 18), "adult", "minor"),
|
|
911
|
-
* }))
|
|
912
|
-
* // SELECT IF(age >= 18, 'adult', 'minor') AS type
|
|
913
|
-
* ```
|
|
914
463
|
*/
|
|
915
464
|
if<T extends ColumnPrimitive>(condition: WhereExprUnit, then: ExprInput<T>, else_: ExprInput<T>): ExprUnit<T>;
|
|
916
465
|
/**
|
|
@@ -919,17 +468,6 @@ export declare const expr: {
|
|
|
919
468
|
* @param arg - Column to count (all rows if omitted)
|
|
920
469
|
* @param distinct - If true, remove duplicates
|
|
921
470
|
* @returns Row count
|
|
922
|
-
*
|
|
923
|
-
* @example
|
|
924
|
-
* ```typescript
|
|
925
|
-
* // Total row count
|
|
926
|
-
* db.user().select(() => ({ total: expr.count() }))
|
|
927
|
-
*
|
|
928
|
-
* // Distinct count
|
|
929
|
-
* db.order().select((o) => ({
|
|
930
|
-
* uniqueCustomers: expr.count(o.customerId, true),
|
|
931
|
-
* }))
|
|
932
|
-
* ```
|
|
933
471
|
*/
|
|
934
472
|
count(arg?: ExprUnit<ColumnPrimitive>, distinct?: boolean): ExprUnit<number>;
|
|
935
473
|
/**
|
|
@@ -939,14 +477,6 @@ export declare const expr: {
|
|
|
939
477
|
*
|
|
940
478
|
* @param arg - Number column to sum
|
|
941
479
|
* @returns Sum (or NULL)
|
|
942
|
-
*
|
|
943
|
-
* @example
|
|
944
|
-
* ```typescript
|
|
945
|
-
* db.order().groupBy((o) => o.userId).select((o) => ({
|
|
946
|
-
* userId: o.userId,
|
|
947
|
-
* totalAmount: expr.sum(o.amount),
|
|
948
|
-
* }))
|
|
949
|
-
* ```
|
|
950
480
|
*/
|
|
951
481
|
sum(arg: ExprUnit<number | undefined>): ExprUnit<number | undefined>;
|
|
952
482
|
/**
|
|
@@ -956,14 +486,6 @@ export declare const expr: {
|
|
|
956
486
|
*
|
|
957
487
|
* @param arg - Number column to average
|
|
958
488
|
* @returns Average (or NULL)
|
|
959
|
-
*
|
|
960
|
-
* @example
|
|
961
|
-
* ```typescript
|
|
962
|
-
* db.product().groupBy((p) => p.categoryId).select((p) => ({
|
|
963
|
-
* categoryId: p.categoryId,
|
|
964
|
-
* avgPrice: expr.avg(p.price),
|
|
965
|
-
* }))
|
|
966
|
-
* ```
|
|
967
489
|
*/
|
|
968
490
|
avg(arg: ExprUnit<number | undefined>): ExprUnit<number | undefined>;
|
|
969
491
|
/**
|
|
@@ -973,14 +495,6 @@ export declare const expr: {
|
|
|
973
495
|
*
|
|
974
496
|
* @param arg - Column to find maximum of
|
|
975
497
|
* @returns Maximum value (or NULL)
|
|
976
|
-
*
|
|
977
|
-
* @example
|
|
978
|
-
* ```typescript
|
|
979
|
-
* db.order().groupBy((o) => o.userId).select((o) => ({
|
|
980
|
-
* userId: o.userId,
|
|
981
|
-
* lastOrderDate: expr.max(o.createdAt),
|
|
982
|
-
* }))
|
|
983
|
-
* ```
|
|
984
498
|
*/
|
|
985
499
|
max<T extends ColumnPrimitive>(arg: ExprUnit<T>): ExprUnit<T | undefined>;
|
|
986
500
|
/**
|
|
@@ -990,14 +504,6 @@ export declare const expr: {
|
|
|
990
504
|
*
|
|
991
505
|
* @param arg - Column to find minimum of
|
|
992
506
|
* @returns Minimum value (or NULL)
|
|
993
|
-
*
|
|
994
|
-
* @example
|
|
995
|
-
* ```typescript
|
|
996
|
-
* db.product().groupBy((p) => p.categoryId).select((p) => ({
|
|
997
|
-
* categoryId: p.categoryId,
|
|
998
|
-
* minPrice: expr.min(p.price),
|
|
999
|
-
* }))
|
|
1000
|
-
* ```
|
|
1001
507
|
*/
|
|
1002
508
|
min<T extends ColumnPrimitive>(arg: ExprUnit<T>): ExprUnit<T | undefined>;
|
|
1003
509
|
/**
|
|
@@ -1005,14 +511,6 @@ export declare const expr: {
|
|
|
1005
511
|
*
|
|
1006
512
|
* @param args - Values to compare
|
|
1007
513
|
* @returns Greatest value
|
|
1008
|
-
*
|
|
1009
|
-
* @example
|
|
1010
|
-
* ```typescript
|
|
1011
|
-
* db.product().select((p) => ({
|
|
1012
|
-
* effectivePrice: expr.greatest(p.price, p.minPrice),
|
|
1013
|
-
* }))
|
|
1014
|
-
* // SELECT GREATEST(price, minPrice) AS effectivePrice
|
|
1015
|
-
* ```
|
|
1016
514
|
*/
|
|
1017
515
|
greatest<T extends ColumnPrimitive>(...args: ExprInput<T>[]): ExprUnit<T>;
|
|
1018
516
|
/**
|
|
@@ -1020,28 +518,12 @@ export declare const expr: {
|
|
|
1020
518
|
*
|
|
1021
519
|
* @param args - Values to compare
|
|
1022
520
|
* @returns Least value
|
|
1023
|
-
*
|
|
1024
|
-
* @example
|
|
1025
|
-
* ```typescript
|
|
1026
|
-
* db.product().select((p) => ({
|
|
1027
|
-
* effectivePrice: expr.least(p.price, p.maxDiscount),
|
|
1028
|
-
* }))
|
|
1029
|
-
* // SELECT LEAST(price, maxDiscount) AS effectivePrice
|
|
1030
|
-
* ```
|
|
1031
521
|
*/
|
|
1032
522
|
least<T extends ColumnPrimitive>(...args: ExprInput<T>[]): ExprUnit<T>;
|
|
1033
523
|
/**
|
|
1034
524
|
* 행 번호 (ROW_NUMBER 없이 모든 행에 순번 부여)
|
|
1035
525
|
*
|
|
1036
526
|
* @returns Row number (starting from 1)
|
|
1037
|
-
*
|
|
1038
|
-
* @example
|
|
1039
|
-
* ```typescript
|
|
1040
|
-
* db.user().select((u) => ({
|
|
1041
|
-
* rowNum: expr.rowNum(),
|
|
1042
|
-
* name: u.name,
|
|
1043
|
-
* }))
|
|
1044
|
-
* ```
|
|
1045
527
|
*/
|
|
1046
528
|
rowNum(): ExprUnit<number>;
|
|
1047
529
|
/**
|
|
@@ -1050,12 +532,6 @@ export declare const expr: {
|
|
|
1050
532
|
* 0과 1 사이의 난수 반환. 주로 ORDER BY에서 무작위 정렬에 사용
|
|
1051
533
|
*
|
|
1052
534
|
* @returns Random number between 0 and 1
|
|
1053
|
-
*
|
|
1054
|
-
* @example
|
|
1055
|
-
* ```typescript
|
|
1056
|
-
* // Random sorting
|
|
1057
|
-
* db.user().orderBy(() => expr.random()).limit(10)
|
|
1058
|
-
* ```
|
|
1059
535
|
*/
|
|
1060
536
|
random(): ExprUnit<number>;
|
|
1061
537
|
/**
|
|
@@ -1064,14 +540,6 @@ export declare const expr: {
|
|
|
1064
540
|
* @param source - Expression to transform
|
|
1065
541
|
* @param targetType - Target data type
|
|
1066
542
|
* @returns Transformed expression
|
|
1067
|
-
*
|
|
1068
|
-
* @example
|
|
1069
|
-
* ```typescript
|
|
1070
|
-
* db.order().select((o) => ({
|
|
1071
|
-
* idStr: expr.cast(o.id, { type: "varchar", length: 20 }),
|
|
1072
|
-
* }))
|
|
1073
|
-
* // SELECT CAST(id AS VARCHAR(20)) AS idStr
|
|
1074
|
-
* ```
|
|
1075
543
|
*/
|
|
1076
544
|
cast<T extends ColumnPrimitive, TDataType extends DataType>(source: ExprUnit<T>, targetType: TDataType): ExprUnit<T extends undefined ? undefined : InferColumnPrimitiveFromDataType<TDataType>>;
|
|
1077
545
|
/**
|
|
@@ -1082,20 +550,6 @@ export declare const expr: {
|
|
|
1082
550
|
* @param dataType - Data type of the returned value
|
|
1083
551
|
* @param queryable - Queryable that returns a scalar value
|
|
1084
552
|
* @returns Subquery result expression
|
|
1085
|
-
*
|
|
1086
|
-
* @example
|
|
1087
|
-
* ```typescript
|
|
1088
|
-
* db.user().select((u) => ({
|
|
1089
|
-
* id: u.id,
|
|
1090
|
-
* postCount: expr.subquery(
|
|
1091
|
-
* "number",
|
|
1092
|
-
* db.post()
|
|
1093
|
-
* .where((p) => [expr.eq(p.userId, u.id)])
|
|
1094
|
-
* .select(() => ({ cnt: expr.count() }))
|
|
1095
|
-
* ),
|
|
1096
|
-
* }))
|
|
1097
|
-
* // SELECT id, (SELECT COUNT(*) FROM Post WHERE userId = User.id) AS postCount
|
|
1098
|
-
* ```
|
|
1099
553
|
*/
|
|
1100
554
|
subquery<TStr extends ColumnPrimitiveStr>(dataType: TStr, queryable: {
|
|
1101
555
|
getSelectQueryDef(): SelectQueryDef;
|
|
@@ -1107,18 +561,6 @@ export declare const expr: {
|
|
|
1107
561
|
*
|
|
1108
562
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1109
563
|
* @returns Row number (starting from 1)
|
|
1110
|
-
*
|
|
1111
|
-
* @example
|
|
1112
|
-
* ```typescript
|
|
1113
|
-
* db.order().select((o) => ({
|
|
1114
|
-
* ...o,
|
|
1115
|
-
* rowNum: expr.rowNumber({
|
|
1116
|
-
* partitionBy: [o.userId],
|
|
1117
|
-
* orderBy: [[o.createdAt, "DESC"]],
|
|
1118
|
-
* }),
|
|
1119
|
-
* }))
|
|
1120
|
-
* // SELECT *, ROW_NUMBER() OVER (PARTITION BY userId ORDER BY createdAt DESC)
|
|
1121
|
-
* ```
|
|
1122
564
|
*/
|
|
1123
565
|
rowNumber(spec: WinSpecInput): ExprUnit<number>;
|
|
1124
566
|
/**
|
|
@@ -1126,16 +568,6 @@ export declare const expr: {
|
|
|
1126
568
|
*
|
|
1127
569
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1128
570
|
* @returns Rank (skips after ties: 1, 1, 3)
|
|
1129
|
-
*
|
|
1130
|
-
* @example
|
|
1131
|
-
* ```typescript
|
|
1132
|
-
* db.student().select((s) => ({
|
|
1133
|
-
* name: s.name,
|
|
1134
|
-
* rank: expr.rank({
|
|
1135
|
-
* orderBy: [[s.score, "DESC"]],
|
|
1136
|
-
* }),
|
|
1137
|
-
* }))
|
|
1138
|
-
* ```
|
|
1139
571
|
*/
|
|
1140
572
|
rank(spec: WinSpecInput): ExprUnit<number>;
|
|
1141
573
|
/**
|
|
@@ -1143,16 +575,6 @@ export declare const expr: {
|
|
|
1143
575
|
*
|
|
1144
576
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1145
577
|
* @returns Dense rank (consecutive after ties: 1, 1, 2)
|
|
1146
|
-
*
|
|
1147
|
-
* @example
|
|
1148
|
-
* ```typescript
|
|
1149
|
-
* db.student().select((s) => ({
|
|
1150
|
-
* name: s.name,
|
|
1151
|
-
* denseRank: expr.denseRank({
|
|
1152
|
-
* orderBy: [[s.score, "DESC"]],
|
|
1153
|
-
* }),
|
|
1154
|
-
* }))
|
|
1155
|
-
* ```
|
|
1156
578
|
*/
|
|
1157
579
|
denseRank(spec: WinSpecInput): ExprUnit<number>;
|
|
1158
580
|
/**
|
|
@@ -1161,17 +583,6 @@ export declare const expr: {
|
|
|
1161
583
|
* @param n - Number of groups to split into
|
|
1162
584
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1163
585
|
* @returns Group number (1 ~ n)
|
|
1164
|
-
*
|
|
1165
|
-
* @example
|
|
1166
|
-
* ```typescript
|
|
1167
|
-
* // Quartile split to find top 25%
|
|
1168
|
-
* db.user().select((u) => ({
|
|
1169
|
-
* name: u.name,
|
|
1170
|
-
* quartile: expr.ntile(4, {
|
|
1171
|
-
* orderBy: [[u.score, "DESC"]],
|
|
1172
|
-
* }),
|
|
1173
|
-
* }))
|
|
1174
|
-
* ```
|
|
1175
586
|
*/
|
|
1176
587
|
ntile(n: number, spec: WinSpecInput): ExprUnit<number>;
|
|
1177
588
|
/**
|
|
@@ -1181,18 +592,6 @@ export declare const expr: {
|
|
|
1181
592
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1182
593
|
* @param options - offset (default 1), default (default value when no previous row)
|
|
1183
594
|
* @returns Previous row's value (or default value/NULL)
|
|
1184
|
-
*
|
|
1185
|
-
* @example
|
|
1186
|
-
* ```typescript
|
|
1187
|
-
* db.stock().select((s) => ({
|
|
1188
|
-
* date: s.date,
|
|
1189
|
-
* price: s.price,
|
|
1190
|
-
* prevPrice: expr.lag(s.price, {
|
|
1191
|
-
* partitionBy: [s.symbol],
|
|
1192
|
-
* orderBy: [[s.date, "ASC"]],
|
|
1193
|
-
* }),
|
|
1194
|
-
* }))
|
|
1195
|
-
* ```
|
|
1196
595
|
*/
|
|
1197
596
|
lag<T extends ColumnPrimitive>(column: ExprUnit<T>, spec: WinSpecInput, options?: {
|
|
1198
597
|
offset?: number;
|
|
@@ -1205,18 +604,6 @@ export declare const expr: {
|
|
|
1205
604
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1206
605
|
* @param options - offset (default 1), default (default value when no following row)
|
|
1207
606
|
* @returns Following row's value (or default value/NULL)
|
|
1208
|
-
*
|
|
1209
|
-
* @example
|
|
1210
|
-
* ```typescript
|
|
1211
|
-
* db.stock().select((s) => ({
|
|
1212
|
-
* date: s.date,
|
|
1213
|
-
* price: s.price,
|
|
1214
|
-
* nextPrice: expr.lead(s.price, {
|
|
1215
|
-
* partitionBy: [s.symbol],
|
|
1216
|
-
* orderBy: [[s.date, "ASC"]],
|
|
1217
|
-
* }),
|
|
1218
|
-
* }))
|
|
1219
|
-
* ```
|
|
1220
607
|
*/
|
|
1221
608
|
lead<T extends ColumnPrimitive>(column: ExprUnit<T>, spec: WinSpecInput, options?: {
|
|
1222
609
|
offset?: number;
|
|
@@ -1228,17 +615,6 @@ export declare const expr: {
|
|
|
1228
615
|
* @param column - Column to reference
|
|
1229
616
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1230
617
|
* @returns First value
|
|
1231
|
-
*
|
|
1232
|
-
* @example
|
|
1233
|
-
* ```typescript
|
|
1234
|
-
* db.order().select((o) => ({
|
|
1235
|
-
* ...o,
|
|
1236
|
-
* firstOrderAmount: expr.firstValue(o.amount, {
|
|
1237
|
-
* partitionBy: [o.userId],
|
|
1238
|
-
* orderBy: [[o.createdAt, "ASC"]],
|
|
1239
|
-
* }),
|
|
1240
|
-
* }))
|
|
1241
|
-
* ```
|
|
1242
618
|
*/
|
|
1243
619
|
firstValue<T extends ColumnPrimitive>(column: ExprUnit<T>, spec: WinSpecInput): ExprUnit<T | undefined>;
|
|
1244
620
|
/**
|
|
@@ -1247,17 +623,6 @@ export declare const expr: {
|
|
|
1247
623
|
* @param column - Column to reference
|
|
1248
624
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1249
625
|
* @returns Last value
|
|
1250
|
-
*
|
|
1251
|
-
* @example
|
|
1252
|
-
* ```typescript
|
|
1253
|
-
* db.order().select((o) => ({
|
|
1254
|
-
* ...o,
|
|
1255
|
-
* lastOrderAmount: expr.lastValue(o.amount, {
|
|
1256
|
-
* partitionBy: [o.userId],
|
|
1257
|
-
* orderBy: [[o.createdAt, "ASC"]],
|
|
1258
|
-
* }),
|
|
1259
|
-
* }))
|
|
1260
|
-
* ```
|
|
1261
626
|
*/
|
|
1262
627
|
lastValue<T extends ColumnPrimitive>(column: ExprUnit<T>, spec: WinSpecInput): ExprUnit<T | undefined>;
|
|
1263
628
|
/**
|
|
@@ -1266,18 +631,6 @@ export declare const expr: {
|
|
|
1266
631
|
* @param column - Column to sum
|
|
1267
632
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1268
633
|
* @returns Sum within window
|
|
1269
|
-
*
|
|
1270
|
-
* @example
|
|
1271
|
-
* ```typescript
|
|
1272
|
-
* // Running total
|
|
1273
|
-
* db.order().select((o) => ({
|
|
1274
|
-
* ...o,
|
|
1275
|
-
* runningTotal: expr.sumOver(o.amount, {
|
|
1276
|
-
* partitionBy: [o.userId],
|
|
1277
|
-
* orderBy: [[o.createdAt, "ASC"]],
|
|
1278
|
-
* }),
|
|
1279
|
-
* }))
|
|
1280
|
-
* ```
|
|
1281
634
|
*/
|
|
1282
635
|
sumOver(column: ExprUnit<number | undefined>, spec: WinSpecInput): ExprUnit<number | undefined>;
|
|
1283
636
|
/**
|
|
@@ -1286,18 +639,6 @@ export declare const expr: {
|
|
|
1286
639
|
* @param column - Column to average
|
|
1287
640
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1288
641
|
* @returns Average within window
|
|
1289
|
-
*
|
|
1290
|
-
* @example
|
|
1291
|
-
* ```typescript
|
|
1292
|
-
* // Moving average
|
|
1293
|
-
* db.stock().select((s) => ({
|
|
1294
|
-
* ...s,
|
|
1295
|
-
* movingAvg: expr.avgOver(s.price, {
|
|
1296
|
-
* partitionBy: [s.symbol],
|
|
1297
|
-
* orderBy: [[s.date, "ASC"]],
|
|
1298
|
-
* }),
|
|
1299
|
-
* }))
|
|
1300
|
-
* ```
|
|
1301
642
|
*/
|
|
1302
643
|
avgOver(column: ExprUnit<number | undefined>, spec: WinSpecInput): ExprUnit<number | undefined>;
|
|
1303
644
|
/**
|
|
@@ -1306,16 +647,6 @@ export declare const expr: {
|
|
|
1306
647
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1307
648
|
* @param column - Column to count (all rows if omitted)
|
|
1308
649
|
* @returns Row count within window
|
|
1309
|
-
*
|
|
1310
|
-
* @example
|
|
1311
|
-
* ```typescript
|
|
1312
|
-
* db.order().select((o) => ({
|
|
1313
|
-
* ...o,
|
|
1314
|
-
* totalOrdersPerUser: expr.countOver({
|
|
1315
|
-
* partitionBy: [o.userId],
|
|
1316
|
-
* }),
|
|
1317
|
-
* }))
|
|
1318
|
-
* ```
|
|
1319
650
|
*/
|
|
1320
651
|
countOver(spec: WinSpecInput, column?: ExprUnit<ColumnPrimitive>): ExprUnit<number>;
|
|
1321
652
|
/**
|
|
@@ -1324,16 +655,6 @@ export declare const expr: {
|
|
|
1324
655
|
* @param column - Column to find minimum of
|
|
1325
656
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1326
657
|
* @returns Minimum value within window
|
|
1327
|
-
*
|
|
1328
|
-
* @example
|
|
1329
|
-
* ```typescript
|
|
1330
|
-
* db.stock().select((s) => ({
|
|
1331
|
-
* ...s,
|
|
1332
|
-
* minPriceInPeriod: expr.minOver(s.price, {
|
|
1333
|
-
* partitionBy: [s.symbol],
|
|
1334
|
-
* }),
|
|
1335
|
-
* }))
|
|
1336
|
-
* ```
|
|
1337
658
|
*/
|
|
1338
659
|
minOver<T extends ColumnPrimitive>(column: ExprUnit<T>, spec: WinSpecInput): ExprUnit<T | undefined>;
|
|
1339
660
|
/**
|
|
@@ -1342,16 +663,6 @@ export declare const expr: {
|
|
|
1342
663
|
* @param column - Column to find maximum of
|
|
1343
664
|
* @param spec - Window spec (partitionBy, orderBy)
|
|
1344
665
|
* @returns Maximum value within window
|
|
1345
|
-
*
|
|
1346
|
-
* @example
|
|
1347
|
-
* ```typescript
|
|
1348
|
-
* db.stock().select((s) => ({
|
|
1349
|
-
* ...s,
|
|
1350
|
-
* maxPriceInPeriod: expr.maxOver(s.price, {
|
|
1351
|
-
* partitionBy: [s.symbol],
|
|
1352
|
-
* }),
|
|
1353
|
-
* }))
|
|
1354
|
-
* ```
|
|
1355
666
|
*/
|
|
1356
667
|
maxOver<T extends ColumnPrimitive>(column: ExprUnit<T>, spec: WinSpecInput): ExprUnit<T | undefined>;
|
|
1357
668
|
/**
|