litedbmodel 2.2.7 → 2.2.9
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/README.md +2 -1
- package/dist/Column.d.ts +13 -2
- package/dist/Column.d.ts.map +1 -1
- package/dist/Column.js +30 -10
- package/dist/Column.js.map +1 -1
- package/dist/DBModel.d.ts +15 -2
- package/dist/DBModel.d.ts.map +1 -1
- package/dist/DBModel.js +40 -25
- package/dist/DBModel.js.map +1 -1
- package/dist/TypeCast.d.ts +2 -2
- package/dist/TypeCast.d.ts.map +1 -1
- package/dist/TypeCast.js +7 -9
- package/dist/TypeCast.js.map +1 -1
- package/dist/decorators.d.ts +10 -1
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +38 -23
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/MysqlHelper.d.ts +3 -3
- package/dist/drivers/MysqlHelper.d.ts.map +1 -1
- package/dist/drivers/MysqlHelper.js +3 -17
- package/dist/drivers/MysqlHelper.js.map +1 -1
- package/dist/drivers/MysqlSqlBuilder.d.ts.map +1 -1
- package/dist/drivers/MysqlSqlBuilder.js +2 -13
- package/dist/drivers/MysqlSqlBuilder.js.map +1 -1
- package/dist/drivers/PostgresHelper.d.ts +3 -2
- package/dist/drivers/PostgresHelper.d.ts.map +1 -1
- package/dist/drivers/PostgresHelper.js +3 -16
- package/dist/drivers/PostgresHelper.js.map +1 -1
- package/dist/drivers/PostgresSqlBuilder.d.ts.map +1 -1
- package/dist/drivers/PostgresSqlBuilder.js +2 -14
- package/dist/drivers/PostgresSqlBuilder.js.map +1 -1
- package/dist/drivers/SqliteHelper.d.ts +4 -2
- package/dist/drivers/SqliteHelper.d.ts.map +1 -1
- package/dist/drivers/SqliteHelper.js +4 -2
- package/dist/drivers/SqliteHelper.js.map +1 -1
- package/dist/drivers/SqliteSqlBuilder.d.ts.map +1 -1
- package/dist/drivers/SqliteSqlBuilder.js +2 -13
- package/dist/drivers/SqliteSqlBuilder.js.map +1 -1
- package/dist/index.cjs +670 -687
- package/dist/scp/decorator-adapter.d.ts +1 -0
- package/dist/scp/decorator-adapter.d.ts.map +1 -1
- package/dist/scp/decorator-adapter.js +2 -0
- package/dist/scp/decorator-adapter.js.map +1 -1
- package/dist/scp/index.cjs +63 -52
- package/dist/scp/index.mjs +63 -52
- package/docs/BENCHMARK.md +1 -1
- package/docs/COMPARISON.md +1 -1
- package/docs/api/README.md +1 -1
- package/docs/api/classes/Conditions.md +10 -10
- package/docs/api/classes/DBHandler.md +1 -1
- package/docs/api/classes/DBModel.md +81 -81
- package/docs/api/classes/LimitExceededError.md +1 -1
- package/docs/api/classes/Middleware.md +1 -1
- package/docs/api/classes/SqlRaw.md +1 -1
- package/docs/api/classes/SqlRef.md +1 -1
- package/docs/api/classes/Values.md +6 -6
- package/docs/api/classes/WriteInReadOnlyContextError.md +1 -1
- package/docs/api/classes/WriteOutsideTransactionError.md +1 -1
- package/docs/api/functions/belongsTo.md +2 -2
- package/docs/api/functions/closeAllPools.md +1 -1
- package/docs/api/functions/condsToRecord.md +4 -3
- package/docs/api/functions/createMiddleware.md +1 -1
- package/docs/api/functions/createPostgresDriver.md +1 -1
- package/docs/api/functions/createSqliteDriver.md +1 -1
- package/docs/api/functions/dbCast.md +1 -1
- package/docs/api/functions/dbCastIn.md +1 -1
- package/docs/api/functions/dbDynamic.md +1 -1
- package/docs/api/functions/dbFalse.md +1 -1
- package/docs/api/functions/dbImmediate.md +1 -1
- package/docs/api/functions/dbIn.md +1 -1
- package/docs/api/functions/dbNotNull.md +1 -1
- package/docs/api/functions/dbNow.md +1 -1
- package/docs/api/functions/dbNull.md +1 -1
- package/docs/api/functions/dbRaw.md +1 -1
- package/docs/api/functions/dbTrue.md +1 -1
- package/docs/api/functions/dbUuid.md +1 -1
- package/docs/api/functions/dbUuidIn.md +1 -1
- package/docs/api/functions/formatLocalDate.md +2 -2
- package/docs/api/functions/formatUTCDate.md +2 -2
- package/docs/api/functions/getDBConfig.md +1 -1
- package/docs/api/functions/getDBHandler.md +1 -1
- package/docs/api/functions/getTransactionConnection.md +2 -2
- package/docs/api/functions/getTransactionContext.md +2 -2
- package/docs/api/functions/hasMany.md +2 -2
- package/docs/api/functions/hasOne.md +2 -2
- package/docs/api/functions/initDBHandler.md +1 -1
- package/docs/api/functions/isAnySqlFragment.md +1 -1
- package/docs/api/functions/isConnectionError.md +1 -1
- package/docs/api/functions/isSqlCondition.md +1 -1
- package/docs/api/functions/isSqlFragment.md +1 -1
- package/docs/api/functions/isSqlRaw.md +1 -1
- package/docs/api/functions/isSqlRef.md +1 -1
- package/docs/api/functions/isSqlTypedFragment.md +1 -1
- package/docs/api/functions/model.md +4 -4
- package/docs/api/functions/parentRef.md +1 -1
- package/docs/api/functions/sql.md +1 -1
- package/docs/api/globals.md +24 -21
- package/docs/api/interfaces/Column.md +32 -31
- package/docs/api/interfaces/ColumnDecorator.md +1 -1
- package/docs/api/interfaces/ColumnOptions.md +1 -1
- package/docs/api/interfaces/CreatedMiddlewareClass.md +1 -1
- package/docs/api/interfaces/DBConfig.md +1 -1
- package/docs/api/interfaces/DBConfigOptions.md +1 -1
- package/docs/api/interfaces/DeleteOptions.md +1 -1
- package/docs/api/interfaces/InsertOptions.md +1 -1
- package/docs/api/interfaces/LimitConfig.md +1 -1
- package/docs/api/interfaces/MiddlewareConfig.md +1 -1
- package/docs/api/interfaces/ModelClassDecorator.md +4 -4
- package/docs/api/interfaces/ModelOptions.md +1 -1
- package/docs/api/interfaces/PkeyResult.md +1 -1
- package/docs/api/interfaces/RelationDecorator.md +1 -1
- package/docs/api/interfaces/SelectOptions.md +1 -1
- package/docs/api/interfaces/SqlCondition.md +1 -1
- package/docs/api/interfaces/SqlFragment.md +1 -1
- package/docs/api/interfaces/SqlTypedFragment.md +1 -1
- package/docs/api/interfaces/TransactionOptions.md +1 -1
- package/docs/api/interfaces/UpdateManyOptions.md +1 -1
- package/docs/api/interfaces/UpdateOptions.md +1 -1
- package/docs/architecture.md +12 -8
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: Values\<Model\>
|
|
8
8
|
|
|
9
|
-
Defined in: [Column.ts:
|
|
9
|
+
Defined in: [Column.ts:577](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L577)
|
|
10
10
|
|
|
11
11
|
Type-safe builder for update/create value pairs.
|
|
12
12
|
Use array literals for static values, builder for dynamic construction.
|
|
@@ -48,7 +48,7 @@ await User.create(values.build());
|
|
|
48
48
|
new Values<Model>(initial?: readonly readonly [Column<any, Model>, unknown][]): Values<Model>;
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
Defined in: [Column.ts:
|
|
51
|
+
Defined in: [Column.ts:583](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L583)
|
|
52
52
|
|
|
53
53
|
Create a Values builder, optionally with initial pairs.
|
|
54
54
|
|
|
@@ -72,7 +72,7 @@ Create a Values builder, optionally with initial pairs.
|
|
|
72
72
|
get length(): number;
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
Defined in: [Column.ts:
|
|
75
|
+
Defined in: [Column.ts:607](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L607)
|
|
76
76
|
|
|
77
77
|
Get the number of pairs.
|
|
78
78
|
|
|
@@ -88,7 +88,7 @@ Get the number of pairs.
|
|
|
88
88
|
add<V>(column: Column<V, Model>, value: V | null | undefined): this;
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
Defined in: [Column.ts:
|
|
91
|
+
Defined in: [Column.ts:592](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L592)
|
|
92
92
|
|
|
93
93
|
Add a type-safe column-value pair.
|
|
94
94
|
|
|
@@ -117,7 +117,7 @@ Add a type-safe column-value pair.
|
|
|
117
117
|
build(): readonly readonly [Column<any, any>, unknown][];
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
Defined in: [Column.ts:
|
|
120
|
+
Defined in: [Column.ts:600](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L600)
|
|
121
121
|
|
|
122
122
|
Build the final array for use with update/create.
|
|
123
123
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function belongsTo<Value>(keys: KeysFactory, options?: RelationDecoratorOptions): RelationDecorator<Value>;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [decorators.ts:
|
|
13
|
+
Defined in: [decorators.ts:1050](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1050)
|
|
14
14
|
|
|
15
15
|
BelongsTo relation decorator (N:1).
|
|
16
16
|
Defines a many-to-one relationship where this model belongs to a parent record.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -7,16 +7,17 @@
|
|
|
7
7
|
# Function: condsToRecord()
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
function condsToRecord(conditions: Conds): Record<string, unknown>;
|
|
10
|
+
function condsToRecord(conditions: Conds, typeCast?: DriverTypeCast): Record<string, unknown>;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [Column.ts:
|
|
13
|
+
Defined in: [Column.ts:1044](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L1044)
|
|
14
14
|
|
|
15
15
|
## Parameters
|
|
16
16
|
|
|
17
17
|
| Parameter | Type |
|
|
18
18
|
| ------ | ------ |
|
|
19
19
|
| `conditions` | `Conds` |
|
|
20
|
+
| `typeCast?` | `DriverTypeCast` |
|
|
20
21
|
|
|
21
22
|
## Returns
|
|
22
23
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function formatLocalDate(d: Date): string;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [TypeCast.ts:
|
|
13
|
+
Defined in: [TypeCast.ts:308](https://github.com/foo-ogawa/litedbmodel/blob/main/src/TypeCast.ts#L308)
|
|
14
14
|
|
|
15
15
|
Format Date as YYYY-MM-DD using local time components
|
|
16
16
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function formatUTCDate(d: Date): string;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [TypeCast.ts:
|
|
13
|
+
Defined in: [TypeCast.ts:316](https://github.com/foo-ogawa/litedbmodel/blob/main/src/TypeCast.ts#L316)
|
|
14
14
|
|
|
15
15
|
Format Date as YYYY-MM-DD using UTC components
|
|
16
16
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function getTransactionConnection(): DBConnection | undefined;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [DBModel.ts:
|
|
13
|
+
Defined in: [DBModel.ts:75](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBModel.ts#L75)
|
|
14
14
|
|
|
15
15
|
Get current transaction connection (if in a transaction)
|
|
16
16
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function getTransactionContext(): TransactionContext | undefined;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [DBModel.ts:
|
|
13
|
+
Defined in: [DBModel.ts:68](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBModel.ts#L68)
|
|
14
14
|
|
|
15
15
|
Get current transaction context (if in a transaction)
|
|
16
16
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function hasMany<Value>(keys: KeysFactory, options?: RelationDecoratorOptions): RelationDecorator<Value>;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [decorators.ts:
|
|
13
|
+
Defined in: [decorators.ts:1020](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1020)
|
|
14
14
|
|
|
15
15
|
HasMany relation decorator (1:N).
|
|
16
16
|
Defines a one-to-many relationship where this model has many related records.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
function hasOne<Value>(keys: KeysFactory, options?: RelationDecoratorOptions): RelationDecorator<Value>;
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Defined in: [decorators.ts:
|
|
13
|
+
Defined in: [decorators.ts:1080](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1080)
|
|
14
14
|
|
|
15
15
|
HasOne relation decorator (1:1).
|
|
16
16
|
Defines a one-to-one relationship where this model has one related record.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
function model<T>(constructor: T): T;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Defined in: [decorators.ts:
|
|
15
|
+
Defined in: [decorators.ts:1149](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1149)
|
|
16
16
|
|
|
17
17
|
### Type Parameters
|
|
18
18
|
|
|
@@ -36,7 +36,7 @@ Defined in: [decorators.ts:1131](https://github.com/foo-ogawa/litedbmodel/blob/m
|
|
|
36
36
|
function model(tableName: string): ModelClassDecorator;
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Defined in: [decorators.ts:
|
|
39
|
+
Defined in: [decorators.ts:1153](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1153)
|
|
40
40
|
|
|
41
41
|
### Parameters
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ Defined in: [decorators.ts:1135](https://github.com/foo-ogawa/litedbmodel/blob/m
|
|
|
54
54
|
function model(tableName: string, options: ModelOptions): ModelClassDecorator;
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Defined in: [decorators.ts:
|
|
57
|
+
Defined in: [decorators.ts:1155](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1155)
|
|
58
58
|
|
|
59
59
|
### Parameters
|
|
60
60
|
|
package/docs/api/globals.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**litedbmodel v2.2.
|
|
1
|
+
[**litedbmodel v2.2.9**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
# litedbmodel v2.2.
|
|
5
|
+
# litedbmodel v2.2.9
|
|
6
6
|
|
|
7
7
|
litedbmodel - A lightweight TypeScript data access layer
|
|
8
8
|
|
|
@@ -77,7 +77,7 @@ Supports PostgreSQL and SQLite databases.
|
|
|
77
77
|
type WriteValue<V> = V | V extends string ? Date | bigint : never;
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
Defined in: [Column.ts:
|
|
80
|
+
Defined in: [Column.ts:780](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L780)
|
|
81
81
|
|
|
82
82
|
What a column ACCEPTS on write, given the type it READS BACK.
|
|
83
83
|
|
|
@@ -102,7 +102,7 @@ from a plain text one — all of them read `string` — so the widening applies
|
|
|
102
102
|
type SkipType = typeof SKIP;
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
Defined in: [Column.ts:
|
|
105
|
+
Defined in: [Column.ts:805](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L805)
|
|
106
106
|
|
|
107
107
|
***
|
|
108
108
|
|
|
@@ -190,6 +190,7 @@ Union of all types allowed as interpolated values in `sql` tagged templates.
|
|
|
190
190
|
```ts
|
|
191
191
|
const column: (_columnNameOrOptions?: string | ColumnOptions) => never & {
|
|
192
192
|
text: (columnNameOrOptions?: string | ColumnOptions) => ColumnDecorator<string | null | undefined>;
|
|
193
|
+
decimal: (columnNameOrOptions?: string | ColumnOptions) => ColumnDecorator<string | null | undefined>;
|
|
193
194
|
boolean: (columnNameOrOptions?: string | ColumnOptions) => ColumnDecorator<boolean | null | undefined>;
|
|
194
195
|
number: (columnNameOrOptions?: string | ColumnOptions) => ColumnDecorator<number | null | undefined>;
|
|
195
196
|
bigint: (columnNameOrOptions?: string | ColumnOptions) => ColumnDecorator<bigint | null | undefined>;
|
|
@@ -207,7 +208,7 @@ const column: (_columnNameOrOptions?: string | ColumnOptions) => never & {
|
|
|
207
208
|
};
|
|
208
209
|
```
|
|
209
210
|
|
|
210
|
-
Defined in: [decorators.ts:
|
|
211
|
+
Defined in: [decorators.ts:598](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L598)
|
|
211
212
|
|
|
212
213
|
Column decorator for defining model properties.
|
|
213
214
|
|
|
@@ -219,6 +220,7 @@ protocol. Nothing is inferred from the TypeScript type annotation.
|
|
|
219
220
|
@column.number({ primaryKey: true, autoIncrement: true }) id?: number;
|
|
220
221
|
@column.text() name?: string; // TEXT / VARCHAR / CHAR / ENUM — no cast needed
|
|
221
222
|
@column.text('custom_name') prop?: string; // custom column name
|
|
223
|
+
@column.decimal() price?: string; // NUMERIC / DECIMAL — exact decimal string
|
|
222
224
|
@column.boolean() is_active?: boolean;
|
|
223
225
|
@column.datetime() created_at?: string; // TZ-attached string, NOT a JS Date
|
|
224
226
|
@column.date() birth_date?: string; // 'YYYY-MM-DD'
|
|
@@ -241,21 +243,22 @@ reports the migration instead (see requireColumnFamily).
|
|
|
241
243
|
|
|
242
244
|
| Name | Type | Description | Defined in |
|
|
243
245
|
| ------ | ------ | ------ | ------ |
|
|
244
|
-
| `text()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string` \| `null` \| `undefined`\> | Text type (TEXT / VARCHAR / CHAR / ENUM / citext) — the driver value is already a string, so no cast is applied. The family still DECLARES the column so the typed read types it as `TEXT`. **Examples** `@column.text() name?: string;` `@column.text('user_name') name?: string;` | [decorators.ts:
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
| `
|
|
251
|
-
| `
|
|
252
|
-
| `
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
246
|
+
| `text()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string` \| `null` \| `undefined`\> | Text type (TEXT / VARCHAR / CHAR / ENUM / citext) — the driver value is already a string, so no cast is applied. The family still DECLARES the column so the typed read types it as `TEXT`. **Examples** `@column.text() name?: string;` `@column.text('user_name') name?: string;` | [decorators.ts:612](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L612) |
|
|
247
|
+
| `decimal()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string` \| `null` \| `undefined`\> | Exact decimal type (NUMERIC / DECIMAL) — read back as its exact decimal STRING (a JS number rounds past 2^53). The family states the column is `numeric`, so a write binds the string as a numeric — a batch write (`createMany` / `updateMany`) included. **Example** `@column.decimal() price?: string;` | [decorators.ts:626](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L626) |
|
|
248
|
+
| `boolean()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`boolean` \| `null` \| `undefined`\> | Boolean type conversion Converts 't'/'f', 'true'/'false', 1/0 to boolean Preserves null for nullable columns, undefined stays undefined **Example** `@column.boolean() is_active?: boolean;` | [decorators.ts:639](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L639) |
|
|
249
|
+
| `number()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`number` \| `null` \| `undefined`\> | Number type conversion (from string) Preserves null for nullable columns, undefined stays undefined **Example** `@column.number() amount?: number;` | [decorators.ts:655](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L655) |
|
|
250
|
+
| `bigint()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`bigint` \| `null` \| `undefined`\> | BigInt type conversion Preserves null for nullable columns, undefined stays undefined **Example** `@column.bigint() large_id?: bigint; // bc `int` — a JS bigint, checked i64` | [decorators.ts:668](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L668) |
|
|
251
|
+
| `datetime()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string` \| `null` \| `undefined`\> | DateTime type conversion (timestamp, timestamptz) Preserves null for nullable columns, undefined stays undefined Timezone handling: - PostgreSQL: Serializes to ISO 8601 UTC string with 'Z' suffix for explicit timezone - MySQL/SQLite: Passes Date object to driver (driver-dependent timezone handling) **Example** `@column.datetime() created_at?: string; // TZ-attached string, NOT a JS Date` | [decorators.ts:695](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L695) |
|
|
252
|
+
| `date()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string` \| `null` \| `undefined`\> | Date type conversion — returns YYYY-MM-DD string. Preserves null for nullable columns, undefined stays undefined. DB values (Date object or string) are normalized to 'YYYY-MM-DD' string. On write, string values are passed through; Date objects are formatted as 'YYYY-MM-DD'. **Example** `@column.date() birth_date?: string; // 'YYYY-MM-DD'` | [decorators.ts:724](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L724) |
|
|
253
|
+
| `stringArray()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string`[] \| `null` \| `undefined`\> | String array type conversion (text[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.stringArray() tags?: string[];` | [decorators.ts:762](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L762) |
|
|
254
|
+
| `intArray()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`number`[] \| `null` \| `undefined`\> | Integer array type conversion (integer[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.intArray() scores?: number[];` | [decorators.ts:778](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L778) |
|
|
255
|
+
| `numericArray()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<(`number` \| `null`)[] \| `null` \| `undefined`\> | Numeric array type conversion (numeric[], allows null elements) Preserves null for nullable columns, undefined stays undefined **Example** `@column.numericArray() values?: (number | null)[];` | [decorators.ts:794](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L794) |
|
|
256
|
+
| `booleanArray()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<(`boolean` \| `null`)[] \| `null` \| `undefined`\> | Boolean array type conversion (boolean[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.booleanArray() flags?: (boolean | null)[];` | [decorators.ts:810](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L810) |
|
|
257
|
+
| `datetimeArray()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<(`string` \| `null`)[] \| `null` \| `undefined`\> | DateTime array type conversion (timestamp[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.datetimeArray() event_dates?: (string | null)[];` | [decorators.ts:826](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L826) |
|
|
258
|
+
| `json()` | \<`T`\>(`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`T` \| `null` \| `undefined`\> | JSON/JSONB type conversion Preserves null for nullable columns, undefined stays undefined **Examples** `@column.json() metadata?: Record<string, unknown>;` `@column.json<UserSettings>() settings?: UserSettings;` | [decorators.ts:856](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L856) |
|
|
259
|
+
| `uuid()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`string` \| `null` \| `undefined`\> | UUID type with automatic casting for PostgreSQL. Automatically adds ::uuid cast to conditions and INSERT/UPDATE values. Preserves null for nullable columns, undefined stays undefined. **Example** `@column.uuid() id?: string; @column.uuid({ primaryKey: true }) id?: string; // Conditions automatically cast to UUID: await User.find([[User.id, 'uuid-string']]); // → WHERE id = ?::uuid // IN clauses also cast: await User.find([[User.id, ['uuid1', 'uuid2']]]); // → WHERE id IN (?::uuid, ?::uuid)` | [decorators.ts:890](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L890) |
|
|
260
|
+
| `passthrough()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`unknown`\> | The driver's value, UNCAST — for a column whose type the library has no cast for (`BYTEA` / `BLOB` arrives as a driver Buffer, a vendor type as whatever the driver decodes). It states "this column is passed through", which is a DECLARATION; the removed bare `@column()` was the absence of one, and produced this same passthrough by accident for every unresolvable type. **Example** `@column.passthrough() payload?: unknown;` | [decorators.ts:913](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L913) |
|
|
261
|
+
| `custom()` | \<`T`\>(`castFn`: (`value`: `unknown`) => `T`, `serializeFn?`: `SerializeFn`, `columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => [`ColumnDecorator`](interfaces/ColumnDecorator.md)\<`T` \| `null` \| `undefined`\> | Custom type conversion with user-provided function **Examples** `@column.custom((v) => String(v).toUpperCase()) status?: string;` `@column.custom((v) => v, (v) => JSON.stringify(v)) data?: MyType; // with serializer` | [decorators.ts:921](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L921) |
|
|
259
262
|
|
|
260
263
|
### Other
|
|
261
264
|
|
|
@@ -265,7 +268,7 @@ reports the migration instead (see requireColumnFamily).
|
|
|
265
268
|
const SKIP: typeof SKIP;
|
|
266
269
|
```
|
|
267
270
|
|
|
268
|
-
Defined in: [Column.ts:
|
|
271
|
+
Defined in: [Column.ts:804](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L804)
|
|
269
272
|
|
|
270
273
|
Sentinel value to skip a field in create/update operations.
|
|
271
274
|
Use with conditional expressions to keep code as expressions instead of statements.
|