@simplysm/orm-common 13.0.83 → 13.0.84
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/ddl/initialize.d.ts +2 -2
- package/dist/ddl/initialize.js +1 -1
- package/dist/ddl/initialize.js.map +1 -1
- package/dist/ddl/table-ddl.d.ts +1 -1
- package/dist/exec/queryable.d.ts +115 -115
- package/dist/exec/queryable.js +68 -68
- package/dist/exec/queryable.js.map +1 -1
- package/dist/expr/expr.d.ts +248 -248
- package/dist/expr/expr.js +250 -250
- package/dist/query-builder/base/expr-renderer-base.d.ts +7 -7
- package/dist/query-builder/mssql/mssql-expr-renderer.d.ts +3 -3
- package/dist/query-builder/mssql/mssql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/mssql/mssql-expr-renderer.js +5 -5
- package/dist/query-builder/mssql/mssql-query-builder.d.ts +2 -2
- package/dist/query-builder/mssql/mssql-query-builder.d.ts.map +1 -1
- package/dist/query-builder/mssql/mssql-query-builder.js +7 -7
- package/dist/query-builder/mysql/mysql-expr-renderer.d.ts +2 -2
- package/dist/query-builder/mysql/mysql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/mysql/mysql-expr-renderer.js +4 -4
- package/dist/query-builder/mysql/mysql-query-builder.d.ts +10 -10
- package/dist/query-builder/mysql/mysql-query-builder.d.ts.map +1 -1
- package/dist/query-builder/mysql/mysql-query-builder.js +4 -4
- package/dist/query-builder/postgresql/postgresql-expr-renderer.d.ts +2 -2
- package/dist/query-builder/postgresql/postgresql-expr-renderer.d.ts.map +1 -1
- package/dist/query-builder/postgresql/postgresql-expr-renderer.js +4 -4
- package/dist/query-builder/postgresql/postgresql-query-builder.d.ts +8 -8
- package/dist/query-builder/postgresql/postgresql-query-builder.d.ts.map +1 -1
- package/dist/query-builder/postgresql/postgresql-query-builder.js +7 -7
- package/dist/query-builder/query-builder.d.ts +1 -1
- package/dist/schema/factory/column-builder.d.ts +46 -46
- package/dist/schema/factory/column-builder.js +25 -25
- package/dist/schema/factory/index-builder.d.ts +22 -22
- package/dist/schema/factory/index-builder.js +14 -14
- package/dist/schema/factory/relation-builder.d.ts +93 -93
- package/dist/schema/factory/relation-builder.d.ts.map +1 -1
- package/dist/schema/factory/relation-builder.js +37 -37
- package/dist/schema/procedure-builder.d.ts +38 -38
- package/dist/schema/procedure-builder.d.ts.map +1 -1
- package/dist/schema/procedure-builder.js +26 -26
- package/dist/schema/table-builder.d.ts +38 -38
- package/dist/schema/table-builder.d.ts.map +1 -1
- package/dist/schema/table-builder.js +29 -29
- package/dist/schema/view-builder.d.ts +26 -26
- package/dist/schema/view-builder.d.ts.map +1 -1
- package/dist/schema/view-builder.js +18 -18
- package/dist/types/db.d.ts +40 -40
- package/dist/types/expr.d.ts +75 -75
- package/dist/types/expr.d.ts.map +1 -1
- package/dist/types/query-def.d.ts +32 -32
- package/dist/types/query-def.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/ddl/initialize.ts +16 -16
- package/src/ddl/table-ddl.ts +1 -1
- package/src/exec/queryable.ts +163 -163
- package/src/expr/expr.ts +257 -257
- package/src/query-builder/base/expr-renderer-base.ts +8 -8
- package/src/query-builder/mssql/mssql-expr-renderer.ts +20 -20
- package/src/query-builder/mssql/mssql-query-builder.ts +28 -28
- package/src/query-builder/mysql/mysql-expr-renderer.ts +22 -22
- package/src/query-builder/mysql/mysql-query-builder.ts +65 -65
- package/src/query-builder/postgresql/postgresql-expr-renderer.ts +15 -15
- package/src/query-builder/postgresql/postgresql-query-builder.ts +43 -43
- package/src/query-builder/query-builder.ts +1 -1
- package/src/schema/factory/column-builder.ts +48 -48
- package/src/schema/factory/index-builder.ts +22 -22
- package/src/schema/factory/relation-builder.ts +95 -95
- package/src/schema/procedure-builder.ts +38 -38
- package/src/schema/table-builder.ts +38 -38
- package/src/schema/view-builder.ts +28 -28
- package/src/types/db.ts +41 -41
- package/src/types/expr.ts +79 -79
- package/src/types/query-def.ts +37 -37
- package/tests/ddl/basic.expected.ts +8 -8
|
@@ -5,8 +5,8 @@ import type { DataRecord } from "../../types/db";
|
|
|
5
5
|
/**
|
|
6
6
|
* Column definition builder
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* TableBuilder.columns()
|
|
8
|
+
* Define column type, nullable, autoIncrement, default, and description via Fluent API
|
|
9
|
+
* Used in TableBuilder.columns()
|
|
10
10
|
*
|
|
11
11
|
* @template TValue - Column value type
|
|
12
12
|
* @template TMeta - Column Metadata type
|
|
@@ -19,7 +19,7 @@ import type { DataRecord } from "../../types/db";
|
|
|
19
19
|
* name: c.varchar(100), // varchar(100), required
|
|
20
20
|
* email: c.varchar(200).nullable(), // varchar(200), nullable
|
|
21
21
|
* status: c.varchar(20).default("active"), // varchar(20), default value
|
|
22
|
-
* createdAt: c.datetime().description("
|
|
22
|
+
* createdAt: c.datetime().description("created datetime"),
|
|
23
23
|
* }));
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
@@ -33,9 +33,9 @@ export declare class ColumnBuilder<TValue extends ColumnPrimitive, TMeta extends
|
|
|
33
33
|
*/
|
|
34
34
|
constructor(meta: TMeta);
|
|
35
35
|
/**
|
|
36
|
-
* Auto Increment
|
|
36
|
+
* Auto Increment configuration
|
|
37
37
|
*
|
|
38
|
-
*
|
|
38
|
+
* Auto increments on INSERT. Treated as optional in INSERT Type inference
|
|
39
39
|
*
|
|
40
40
|
* @returns new ColumnBuilder instance
|
|
41
41
|
*
|
|
@@ -48,9 +48,9 @@ export declare class ColumnBuilder<TValue extends ColumnPrimitive, TMeta extends
|
|
|
48
48
|
autoIncrement: true;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
|
-
* Nullable
|
|
51
|
+
* Nullable configuration
|
|
52
52
|
*
|
|
53
|
-
* Allow NULL.
|
|
53
|
+
* Allow NULL. Adds undefined to the value type
|
|
54
54
|
*
|
|
55
55
|
* @returns new ColumnBuilder instance
|
|
56
56
|
*
|
|
@@ -63,9 +63,9 @@ export declare class ColumnBuilder<TValue extends ColumnPrimitive, TMeta extends
|
|
|
63
63
|
nullable: true;
|
|
64
64
|
}>;
|
|
65
65
|
/**
|
|
66
|
-
* Default value
|
|
66
|
+
* Default value configuration
|
|
67
67
|
*
|
|
68
|
-
*
|
|
68
|
+
* Used when no value is specified on INSERT. Treated as optional in INSERT Type inference
|
|
69
69
|
*
|
|
70
70
|
* @param value - Default value
|
|
71
71
|
* @returns new ColumnBuilder instance
|
|
@@ -82,12 +82,12 @@ export declare class ColumnBuilder<TValue extends ColumnPrimitive, TMeta extends
|
|
|
82
82
|
/**
|
|
83
83
|
* column set description
|
|
84
84
|
*
|
|
85
|
-
* @param desc - Column description (DDL Comment
|
|
85
|
+
* @param desc - Column description (used as DDL Comment)
|
|
86
86
|
* @returns new ColumnBuilder instance
|
|
87
87
|
*
|
|
88
88
|
* @example
|
|
89
89
|
* ```typescript
|
|
90
|
-
* createdAt: c.datetime().description("
|
|
90
|
+
* createdAt: c.datetime().description("record creation datetime")
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
description(desc: string): ColumnBuilder<TValue, TMeta & {
|
|
@@ -95,12 +95,12 @@ export declare class ColumnBuilder<TValue extends ColumnPrimitive, TMeta extends
|
|
|
95
95
|
}>;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
|
-
* Column builder factory
|
|
98
|
+
* Column builder factory creation
|
|
99
99
|
*
|
|
100
|
-
* TableBuilder.columns()
|
|
101
|
-
*
|
|
100
|
+
* Column type factory used in TableBuilder.columns()
|
|
101
|
+
* Provides builder creation methods for all basic data types
|
|
102
102
|
*
|
|
103
|
-
* @returns
|
|
103
|
+
* @returns Object containing builder creation methods for each Column type
|
|
104
104
|
*
|
|
105
105
|
* @example
|
|
106
106
|
* ```typescript
|
|
@@ -111,12 +111,12 @@ export declare class ColumnBuilder<TValue extends ColumnPrimitive, TMeta extends
|
|
|
111
111
|
* count: c.int(),
|
|
112
112
|
* price: c.decimal(10, 2),
|
|
113
113
|
*
|
|
114
|
-
* //
|
|
114
|
+
* // String type
|
|
115
115
|
* name: c.varchar(100),
|
|
116
116
|
* code: c.char(10),
|
|
117
117
|
* content: c.text(),
|
|
118
118
|
*
|
|
119
|
-
* // Date
|
|
119
|
+
* // Date/time type
|
|
120
120
|
* createdAt: c.datetime(),
|
|
121
121
|
* birthDate: c.date(),
|
|
122
122
|
* startTime: c.time(),
|
|
@@ -154,7 +154,7 @@ export declare function createColumnFactory(): {
|
|
|
154
154
|
};
|
|
155
155
|
}>;
|
|
156
156
|
/**
|
|
157
|
-
* FLOAT column (4 bytes,
|
|
157
|
+
* FLOAT column (4 bytes, single-precision floating point)
|
|
158
158
|
*
|
|
159
159
|
* @returns ColumnBuilder instance
|
|
160
160
|
*/
|
|
@@ -165,7 +165,7 @@ export declare function createColumnFactory(): {
|
|
|
165
165
|
};
|
|
166
166
|
}>;
|
|
167
167
|
/**
|
|
168
|
-
* DOUBLE column (8 bytes,
|
|
168
|
+
* DOUBLE column (8 bytes, double-precision floating point)
|
|
169
169
|
*
|
|
170
170
|
* @returns ColumnBuilder instance
|
|
171
171
|
*/
|
|
@@ -176,10 +176,10 @@ export declare function createColumnFactory(): {
|
|
|
176
176
|
};
|
|
177
177
|
}>;
|
|
178
178
|
/**
|
|
179
|
-
* DECIMAL column (
|
|
179
|
+
* DECIMAL column (fixed-point)
|
|
180
180
|
*
|
|
181
|
-
* @param precision -
|
|
182
|
-
* @param scale -
|
|
181
|
+
* @param precision - Total number of digits
|
|
182
|
+
* @param scale - Number of digits after the decimal point (optional)
|
|
183
183
|
* @returns ColumnBuilder instance
|
|
184
184
|
*
|
|
185
185
|
* @example
|
|
@@ -196,9 +196,9 @@ export declare function createColumnFactory(): {
|
|
|
196
196
|
};
|
|
197
197
|
}>;
|
|
198
198
|
/**
|
|
199
|
-
* VARCHAR column (
|
|
199
|
+
* VARCHAR column (variable-length string)
|
|
200
200
|
*
|
|
201
|
-
* @param length -
|
|
201
|
+
* @param length - Maximum length
|
|
202
202
|
* @returns ColumnBuilder instance
|
|
203
203
|
*
|
|
204
204
|
* @example
|
|
@@ -214,9 +214,9 @@ export declare function createColumnFactory(): {
|
|
|
214
214
|
};
|
|
215
215
|
}>;
|
|
216
216
|
/**
|
|
217
|
-
* CHAR column (
|
|
217
|
+
* CHAR column (fixed-length string)
|
|
218
218
|
*
|
|
219
|
-
* @param length -
|
|
219
|
+
* @param length - Fixed length
|
|
220
220
|
* @returns ColumnBuilder instance
|
|
221
221
|
*
|
|
222
222
|
* @example
|
|
@@ -232,7 +232,7 @@ export declare function createColumnFactory(): {
|
|
|
232
232
|
};
|
|
233
233
|
}>;
|
|
234
234
|
/**
|
|
235
|
-
* TEXT column (
|
|
235
|
+
* TEXT column (large text)
|
|
236
236
|
*
|
|
237
237
|
* @returns ColumnBuilder instance
|
|
238
238
|
*/
|
|
@@ -243,9 +243,9 @@ export declare function createColumnFactory(): {
|
|
|
243
243
|
};
|
|
244
244
|
}>;
|
|
245
245
|
/**
|
|
246
|
-
* BINARY column (
|
|
246
|
+
* BINARY column (binary data)
|
|
247
247
|
*
|
|
248
|
-
* DBMS
|
|
248
|
+
* Per DBMS: MySQL=LONGBLOB, MSSQL=VARBINARY(MAX), PostgreSQL=BYTEA
|
|
249
249
|
*
|
|
250
250
|
* @returns ColumnBuilder instance
|
|
251
251
|
*/
|
|
@@ -258,7 +258,7 @@ export declare function createColumnFactory(): {
|
|
|
258
258
|
/**
|
|
259
259
|
* BOOLEAN column
|
|
260
260
|
*
|
|
261
|
-
* DBMS
|
|
261
|
+
* Per DBMS: MySQL=TINYINT(1), MSSQL=BIT, PostgreSQL=BOOLEAN
|
|
262
262
|
*
|
|
263
263
|
* @returns ColumnBuilder instance
|
|
264
264
|
*/
|
|
@@ -269,7 +269,7 @@ export declare function createColumnFactory(): {
|
|
|
269
269
|
};
|
|
270
270
|
}>;
|
|
271
271
|
/**
|
|
272
|
-
* DATETIME column (
|
|
272
|
+
* DATETIME column (date + time)
|
|
273
273
|
*
|
|
274
274
|
* @returns ColumnBuilder instance
|
|
275
275
|
*/
|
|
@@ -280,7 +280,7 @@ export declare function createColumnFactory(): {
|
|
|
280
280
|
};
|
|
281
281
|
}>;
|
|
282
282
|
/**
|
|
283
|
-
* DATE column (
|
|
283
|
+
* DATE column (date only)
|
|
284
284
|
*
|
|
285
285
|
* @returns ColumnBuilder instance
|
|
286
286
|
*/
|
|
@@ -291,7 +291,7 @@ export declare function createColumnFactory(): {
|
|
|
291
291
|
};
|
|
292
292
|
}>;
|
|
293
293
|
/**
|
|
294
|
-
* TIME column (
|
|
294
|
+
* TIME column (time only)
|
|
295
295
|
*
|
|
296
296
|
* @returns ColumnBuilder instance
|
|
297
297
|
*/
|
|
@@ -304,7 +304,7 @@ export declare function createColumnFactory(): {
|
|
|
304
304
|
/**
|
|
305
305
|
* UUID column
|
|
306
306
|
*
|
|
307
|
-
* DBMS
|
|
307
|
+
* Per DBMS: MySQL=BINARY(16), MSSQL=UNIQUEIDENTIFIER, PostgreSQL=UUID
|
|
308
308
|
*
|
|
309
309
|
* @returns ColumnBuilder instance
|
|
310
310
|
*/
|
|
@@ -318,11 +318,11 @@ export declare function createColumnFactory(): {
|
|
|
318
318
|
/**
|
|
319
319
|
* Column builder record type
|
|
320
320
|
*
|
|
321
|
-
* TableBuilder.columns()
|
|
321
|
+
* Used as the return type of TableBuilder.columns()
|
|
322
322
|
*/
|
|
323
323
|
export type ColumnBuilderRecord = Record<string, ColumnBuilder<ColumnPrimitive, ColumnMeta>>;
|
|
324
324
|
/**
|
|
325
|
-
*
|
|
325
|
+
* Infer actual value types from a Column builder record
|
|
326
326
|
*
|
|
327
327
|
* @template T - Column builder record type
|
|
328
328
|
*
|
|
@@ -336,7 +336,7 @@ export type InferColumns<TBuilders extends ColumnBuilderRecord> = {
|
|
|
336
336
|
[K in keyof TBuilders]: TBuilders[K] extends ColumnBuilder<infer V, any> ? V : never;
|
|
337
337
|
};
|
|
338
338
|
/**
|
|
339
|
-
*
|
|
339
|
+
* Infer expression input types from a Column builder record
|
|
340
340
|
*
|
|
341
341
|
* @template T - Column builder record type
|
|
342
342
|
*/
|
|
@@ -344,9 +344,9 @@ export type InferColumnExprs<TBuilders extends ColumnBuilderRecord> = {
|
|
|
344
344
|
[K in keyof TBuilders]: TBuilders[K] extends ColumnBuilder<infer V, any> ? ExprInput<V> : never;
|
|
345
345
|
};
|
|
346
346
|
/**
|
|
347
|
-
*
|
|
347
|
+
* Extract required column keys for INSERT
|
|
348
348
|
*
|
|
349
|
-
* autoIncrement, nullable, default
|
|
349
|
+
* Only columns without autoIncrement, nullable, or default are required
|
|
350
350
|
*
|
|
351
351
|
* @template T - Column builder record type
|
|
352
352
|
*/
|
|
@@ -354,17 +354,17 @@ export type RequiredInsertKeys<TBuilders extends ColumnBuilderRecord> = {
|
|
|
354
354
|
[K in keyof TBuilders]: TBuilders[K]["meta"] extends infer M extends ColumnMeta ? M["autoIncrement"] extends true ? never : M["nullable"] extends true ? never : M["default"] extends undefined ? K : never : never;
|
|
355
355
|
}[keyof TBuilders];
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
* Extract optional column keys for INSERT
|
|
358
358
|
*
|
|
359
|
-
* autoIncrement, nullable, default
|
|
359
|
+
* Columns with autoIncrement, nullable, or default are optional
|
|
360
360
|
*
|
|
361
361
|
* @template T - Column builder record type
|
|
362
362
|
*/
|
|
363
363
|
export type OptionalInsertKeys<TBuilders extends ColumnBuilderRecord> = Exclude<keyof TBuilders, RequiredInsertKeys<TBuilders>>;
|
|
364
364
|
/**
|
|
365
|
-
* INSERT
|
|
365
|
+
* INSERT Type inference
|
|
366
366
|
*
|
|
367
|
-
*
|
|
367
|
+
* Required columns are required, optional columns are Partial
|
|
368
368
|
*
|
|
369
369
|
* @template T - Column builder record type
|
|
370
370
|
*
|
|
@@ -376,15 +376,15 @@ export type OptionalInsertKeys<TBuilders extends ColumnBuilderRecord> = Exclude<
|
|
|
376
376
|
*/
|
|
377
377
|
export type InferInsertColumns<TBuilders extends ColumnBuilderRecord> = Pick<InferColumns<TBuilders>, RequiredInsertKeys<TBuilders>> & Partial<Pick<InferColumns<TBuilders>, OptionalInsertKeys<TBuilders>>>;
|
|
378
378
|
/**
|
|
379
|
-
* UPDATE
|
|
379
|
+
* UPDATE Type inference
|
|
380
380
|
*
|
|
381
|
-
*
|
|
381
|
+
* All columns are optional
|
|
382
382
|
*
|
|
383
383
|
* @template T - Column builder record type
|
|
384
384
|
*/
|
|
385
385
|
export type InferUpdateColumns<TBuilders extends ColumnBuilderRecord> = Partial<InferColumns<TBuilders>>;
|
|
386
386
|
/**
|
|
387
|
-
* data
|
|
387
|
+
* Transform from data record to Column builder record
|
|
388
388
|
*
|
|
389
389
|
* @template TData - data record type
|
|
390
390
|
*/
|
|
@@ -6,9 +6,9 @@ class ColumnBuilder {
|
|
|
6
6
|
this.meta = meta;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Auto Increment
|
|
9
|
+
* Auto Increment configuration
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Auto increments on INSERT. Treated as optional in INSERT Type inference
|
|
12
12
|
*
|
|
13
13
|
* @returns new ColumnBuilder instance
|
|
14
14
|
*
|
|
@@ -21,9 +21,9 @@ class ColumnBuilder {
|
|
|
21
21
|
return new ColumnBuilder({ ...this.meta, autoIncrement: true });
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Nullable
|
|
24
|
+
* Nullable configuration
|
|
25
25
|
*
|
|
26
|
-
* Allow NULL.
|
|
26
|
+
* Allow NULL. Adds undefined to the value type
|
|
27
27
|
*
|
|
28
28
|
* @returns new ColumnBuilder instance
|
|
29
29
|
*
|
|
@@ -36,9 +36,9 @@ class ColumnBuilder {
|
|
|
36
36
|
return new ColumnBuilder({ ...this.meta, nullable: true });
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Default value
|
|
39
|
+
* Default value configuration
|
|
40
40
|
*
|
|
41
|
-
*
|
|
41
|
+
* Used when no value is specified on INSERT. Treated as optional in INSERT Type inference
|
|
42
42
|
*
|
|
43
43
|
* @param value - Default value
|
|
44
44
|
* @returns new ColumnBuilder instance
|
|
@@ -55,12 +55,12 @@ class ColumnBuilder {
|
|
|
55
55
|
/**
|
|
56
56
|
* column set description
|
|
57
57
|
*
|
|
58
|
-
* @param desc - Column description (DDL Comment
|
|
58
|
+
* @param desc - Column description (used as DDL Comment)
|
|
59
59
|
* @returns new ColumnBuilder instance
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
62
62
|
* ```typescript
|
|
63
|
-
* createdAt: c.datetime().description("
|
|
63
|
+
* createdAt: c.datetime().description("record creation datetime")
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
description(desc) {
|
|
@@ -86,7 +86,7 @@ function createColumnFactory() {
|
|
|
86
86
|
return new ColumnBuilder({ type: "number", dataType: { type: "bigint" } });
|
|
87
87
|
},
|
|
88
88
|
/**
|
|
89
|
-
* FLOAT column (4 bytes,
|
|
89
|
+
* FLOAT column (4 bytes, single-precision floating point)
|
|
90
90
|
*
|
|
91
91
|
* @returns ColumnBuilder instance
|
|
92
92
|
*/
|
|
@@ -94,7 +94,7 @@ function createColumnFactory() {
|
|
|
94
94
|
return new ColumnBuilder({ type: "number", dataType: { type: "float" } });
|
|
95
95
|
},
|
|
96
96
|
/**
|
|
97
|
-
* DOUBLE column (8 bytes,
|
|
97
|
+
* DOUBLE column (8 bytes, double-precision floating point)
|
|
98
98
|
*
|
|
99
99
|
* @returns ColumnBuilder instance
|
|
100
100
|
*/
|
|
@@ -102,10 +102,10 @@ function createColumnFactory() {
|
|
|
102
102
|
return new ColumnBuilder({ type: "number", dataType: { type: "double" } });
|
|
103
103
|
},
|
|
104
104
|
/**
|
|
105
|
-
* DECIMAL column (
|
|
105
|
+
* DECIMAL column (fixed-point)
|
|
106
106
|
*
|
|
107
|
-
* @param precision -
|
|
108
|
-
* @param scale -
|
|
107
|
+
* @param precision - Total number of digits
|
|
108
|
+
* @param scale - Number of digits after the decimal point (optional)
|
|
109
109
|
* @returns ColumnBuilder instance
|
|
110
110
|
*
|
|
111
111
|
* @example
|
|
@@ -117,9 +117,9 @@ function createColumnFactory() {
|
|
|
117
117
|
return new ColumnBuilder({ type: "number", dataType: { type: "decimal", precision, scale } });
|
|
118
118
|
},
|
|
119
119
|
/**
|
|
120
|
-
* VARCHAR column (
|
|
120
|
+
* VARCHAR column (variable-length string)
|
|
121
121
|
*
|
|
122
|
-
* @param length -
|
|
122
|
+
* @param length - Maximum length
|
|
123
123
|
* @returns ColumnBuilder instance
|
|
124
124
|
*
|
|
125
125
|
* @example
|
|
@@ -131,9 +131,9 @@ function createColumnFactory() {
|
|
|
131
131
|
return new ColumnBuilder({ type: "string", dataType: { type: "varchar", length } });
|
|
132
132
|
},
|
|
133
133
|
/**
|
|
134
|
-
* CHAR column (
|
|
134
|
+
* CHAR column (fixed-length string)
|
|
135
135
|
*
|
|
136
|
-
* @param length -
|
|
136
|
+
* @param length - Fixed length
|
|
137
137
|
* @returns ColumnBuilder instance
|
|
138
138
|
*
|
|
139
139
|
* @example
|
|
@@ -145,7 +145,7 @@ function createColumnFactory() {
|
|
|
145
145
|
return new ColumnBuilder({ type: "string", dataType: { type: "char", length } });
|
|
146
146
|
},
|
|
147
147
|
/**
|
|
148
|
-
* TEXT column (
|
|
148
|
+
* TEXT column (large text)
|
|
149
149
|
*
|
|
150
150
|
* @returns ColumnBuilder instance
|
|
151
151
|
*/
|
|
@@ -153,9 +153,9 @@ function createColumnFactory() {
|
|
|
153
153
|
return new ColumnBuilder({ type: "string", dataType: { type: "text" } });
|
|
154
154
|
},
|
|
155
155
|
/**
|
|
156
|
-
* BINARY column (
|
|
156
|
+
* BINARY column (binary data)
|
|
157
157
|
*
|
|
158
|
-
* DBMS
|
|
158
|
+
* Per DBMS: MySQL=LONGBLOB, MSSQL=VARBINARY(MAX), PostgreSQL=BYTEA
|
|
159
159
|
*
|
|
160
160
|
* @returns ColumnBuilder instance
|
|
161
161
|
*/
|
|
@@ -165,7 +165,7 @@ function createColumnFactory() {
|
|
|
165
165
|
/**
|
|
166
166
|
* BOOLEAN column
|
|
167
167
|
*
|
|
168
|
-
* DBMS
|
|
168
|
+
* Per DBMS: MySQL=TINYINT(1), MSSQL=BIT, PostgreSQL=BOOLEAN
|
|
169
169
|
*
|
|
170
170
|
* @returns ColumnBuilder instance
|
|
171
171
|
*/
|
|
@@ -173,7 +173,7 @@ function createColumnFactory() {
|
|
|
173
173
|
return new ColumnBuilder({ type: "boolean", dataType: { type: "boolean" } });
|
|
174
174
|
},
|
|
175
175
|
/**
|
|
176
|
-
* DATETIME column (
|
|
176
|
+
* DATETIME column (date + time)
|
|
177
177
|
*
|
|
178
178
|
* @returns ColumnBuilder instance
|
|
179
179
|
*/
|
|
@@ -181,7 +181,7 @@ function createColumnFactory() {
|
|
|
181
181
|
return new ColumnBuilder({ type: "DateTime", dataType: { type: "datetime" } });
|
|
182
182
|
},
|
|
183
183
|
/**
|
|
184
|
-
* DATE column (
|
|
184
|
+
* DATE column (date only)
|
|
185
185
|
*
|
|
186
186
|
* @returns ColumnBuilder instance
|
|
187
187
|
*/
|
|
@@ -189,7 +189,7 @@ function createColumnFactory() {
|
|
|
189
189
|
return new ColumnBuilder({ type: "DateOnly", dataType: { type: "date" } });
|
|
190
190
|
},
|
|
191
191
|
/**
|
|
192
|
-
* TIME column (
|
|
192
|
+
* TIME column (time only)
|
|
193
193
|
*
|
|
194
194
|
* @returns ColumnBuilder instance
|
|
195
195
|
*/
|
|
@@ -199,7 +199,7 @@ function createColumnFactory() {
|
|
|
199
199
|
/**
|
|
200
200
|
* UUID column
|
|
201
201
|
*
|
|
202
|
-
* DBMS
|
|
202
|
+
* Per DBMS: MySQL=BINARY(16), MSSQL=UNIQUEIDENTIFIER, PostgreSQL=UUID
|
|
203
203
|
*
|
|
204
204
|
* @returns ColumnBuilder instance
|
|
205
205
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Index definition builder
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* TableBuilder.indexes()
|
|
4
|
+
* Define Index columns, uniqueness, and sort order via Fluent API
|
|
5
|
+
* Used in TableBuilder.indexes()
|
|
6
6
|
*
|
|
7
7
|
* @template TKeys - Index column key array type
|
|
8
8
|
*
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
* createdAt: c.datetime(),
|
|
17
17
|
* }))
|
|
18
18
|
* .indexes((i) => [
|
|
19
|
-
* //
|
|
19
|
+
* // Unique index
|
|
20
20
|
* i.index("email").unique(),
|
|
21
21
|
*
|
|
22
|
-
* //
|
|
22
|
+
* // Composite index + sort order
|
|
23
23
|
* i.index("name", "createdAt").orderBy("ASC", "DESC"),
|
|
24
24
|
*
|
|
25
|
-
* //
|
|
25
|
+
* // Custom name
|
|
26
26
|
* i.index("createdAt").name("IX_User_CreatedAt"),
|
|
27
27
|
* ]);
|
|
28
28
|
* ```
|
|
@@ -43,9 +43,9 @@ export declare class IndexBuilder<TKeys extends string[]> {
|
|
|
43
43
|
/**
|
|
44
44
|
* @param meta - Index Metadata
|
|
45
45
|
* @param meta.columns - Index column array
|
|
46
|
-
* @param meta.name - Index
|
|
47
|
-
* @param meta.unique -
|
|
48
|
-
* @param meta.orderBy -
|
|
46
|
+
* @param meta.name - Index name (optional)
|
|
47
|
+
* @param meta.unique - Whether it is a unique index
|
|
48
|
+
* @param meta.orderBy - Sort order per column
|
|
49
49
|
* @param meta.description - Index description
|
|
50
50
|
*/
|
|
51
51
|
constructor(meta: {
|
|
@@ -60,7 +60,7 @@ export declare class IndexBuilder<TKeys extends string[]> {
|
|
|
60
60
|
/**
|
|
61
61
|
* Index set name
|
|
62
62
|
*
|
|
63
|
-
* @param name - Index
|
|
63
|
+
* @param name - Index name
|
|
64
64
|
* @returns new IndexBuilder instance
|
|
65
65
|
*
|
|
66
66
|
* @example
|
|
@@ -70,7 +70,7 @@ export declare class IndexBuilder<TKeys extends string[]> {
|
|
|
70
70
|
*/
|
|
71
71
|
name(name: string): IndexBuilder<TKeys>;
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Unique index configuration
|
|
74
74
|
*
|
|
75
75
|
* @returns new IndexBuilder instance
|
|
76
76
|
*
|
|
@@ -81,19 +81,19 @@ export declare class IndexBuilder<TKeys extends string[]> {
|
|
|
81
81
|
*/
|
|
82
82
|
unique(): IndexBuilder<TKeys>;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* Sort order configuration
|
|
85
85
|
*
|
|
86
|
-
*
|
|
86
|
+
* Specify ASC or DESC for each column
|
|
87
87
|
*
|
|
88
|
-
* @param orderBy -
|
|
88
|
+
* @param orderBy - Sort order per column (must match the number of columns)
|
|
89
89
|
* @returns new IndexBuilder instance
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* ```typescript
|
|
93
|
-
* //
|
|
93
|
+
* // Single column
|
|
94
94
|
* i.index("createdAt").orderBy("DESC")
|
|
95
95
|
*
|
|
96
|
-
* //
|
|
96
|
+
* // Composite column
|
|
97
97
|
* i.index("status", "createdAt").orderBy("ASC", "DESC")
|
|
98
98
|
* ```
|
|
99
99
|
*/
|
|
@@ -103,18 +103,18 @@ export declare class IndexBuilder<TKeys extends string[]> {
|
|
|
103
103
|
/**
|
|
104
104
|
* Index set description
|
|
105
105
|
*
|
|
106
|
-
* @param description - Index description (DDL Comment
|
|
106
|
+
* @param description - Index description (used as DDL Comment)
|
|
107
107
|
* @returns new IndexBuilder instance
|
|
108
108
|
*/
|
|
109
109
|
description(description: string): IndexBuilder<TKeys>;
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
* Index builder factory
|
|
112
|
+
* Index builder factory creation
|
|
113
113
|
*
|
|
114
|
-
* TableBuilder.indexes()
|
|
114
|
+
* Index factory used in TableBuilder.indexes()
|
|
115
115
|
*
|
|
116
116
|
* @template TColumnKey - Table column key type
|
|
117
|
-
* @returns
|
|
117
|
+
* @returns Object containing Index creation methods
|
|
118
118
|
*
|
|
119
119
|
* @example
|
|
120
120
|
* ```typescript
|
|
@@ -137,13 +137,13 @@ export declare function createIndexFactory<TColumnKey extends string>(): {
|
|
|
137
137
|
* Index Generate
|
|
138
138
|
*
|
|
139
139
|
* @template TKeys - Index column key array type
|
|
140
|
-
* @param columns - Index column
|
|
140
|
+
* @param columns - Index column names
|
|
141
141
|
* @returns IndexBuilder instance
|
|
142
142
|
*
|
|
143
143
|
* @example
|
|
144
144
|
* ```typescript
|
|
145
|
-
* i.index("email") //
|
|
146
|
-
* i.index("name", "email") //
|
|
145
|
+
* i.index("email") // Single column
|
|
146
|
+
* i.index("name", "email") // Composite column
|
|
147
147
|
* ```
|
|
148
148
|
*/
|
|
149
149
|
index<TKeys extends TColumnKey[]>(...columns: TKeys): IndexBuilder<TKeys>;
|
|
@@ -2,9 +2,9 @@ class IndexBuilder {
|
|
|
2
2
|
/**
|
|
3
3
|
* @param meta - Index Metadata
|
|
4
4
|
* @param meta.columns - Index column array
|
|
5
|
-
* @param meta.name - Index
|
|
6
|
-
* @param meta.unique -
|
|
7
|
-
* @param meta.orderBy -
|
|
5
|
+
* @param meta.name - Index name (optional)
|
|
6
|
+
* @param meta.unique - Whether it is a unique index
|
|
7
|
+
* @param meta.orderBy - Sort order per column
|
|
8
8
|
* @param meta.description - Index description
|
|
9
9
|
*/
|
|
10
10
|
constructor(meta) {
|
|
@@ -13,7 +13,7 @@ class IndexBuilder {
|
|
|
13
13
|
/**
|
|
14
14
|
* Index set name
|
|
15
15
|
*
|
|
16
|
-
* @param name - Index
|
|
16
|
+
* @param name - Index name
|
|
17
17
|
* @returns new IndexBuilder instance
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
@@ -25,7 +25,7 @@ class IndexBuilder {
|
|
|
25
25
|
return new IndexBuilder({ ...this.meta, name });
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Unique index configuration
|
|
29
29
|
*
|
|
30
30
|
* @returns new IndexBuilder instance
|
|
31
31
|
*
|
|
@@ -38,19 +38,19 @@ class IndexBuilder {
|
|
|
38
38
|
return new IndexBuilder({ ...this.meta, unique: true });
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Sort order configuration
|
|
42
42
|
*
|
|
43
|
-
*
|
|
43
|
+
* Specify ASC or DESC for each column
|
|
44
44
|
*
|
|
45
|
-
* @param orderBy -
|
|
45
|
+
* @param orderBy - Sort order per column (must match the number of columns)
|
|
46
46
|
* @returns new IndexBuilder instance
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
49
|
* ```typescript
|
|
50
|
-
* //
|
|
50
|
+
* // Single column
|
|
51
51
|
* i.index("createdAt").orderBy("DESC")
|
|
52
52
|
*
|
|
53
|
-
* //
|
|
53
|
+
* // Composite column
|
|
54
54
|
* i.index("status", "createdAt").orderBy("ASC", "DESC")
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
@@ -60,7 +60,7 @@ class IndexBuilder {
|
|
|
60
60
|
/**
|
|
61
61
|
* Index set description
|
|
62
62
|
*
|
|
63
|
-
* @param description - Index description (DDL Comment
|
|
63
|
+
* @param description - Index description (used as DDL Comment)
|
|
64
64
|
* @returns new IndexBuilder instance
|
|
65
65
|
*/
|
|
66
66
|
description(description) {
|
|
@@ -73,13 +73,13 @@ function createIndexFactory() {
|
|
|
73
73
|
* Index Generate
|
|
74
74
|
*
|
|
75
75
|
* @template TKeys - Index column key array type
|
|
76
|
-
* @param columns - Index column
|
|
76
|
+
* @param columns - Index column names
|
|
77
77
|
* @returns IndexBuilder instance
|
|
78
78
|
*
|
|
79
79
|
* @example
|
|
80
80
|
* ```typescript
|
|
81
|
-
* i.index("email") //
|
|
82
|
-
* i.index("name", "email") //
|
|
81
|
+
* i.index("email") // Single column
|
|
82
|
+
* i.index("name", "email") // Composite column
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
85
|
index(...columns) {
|