litedbmodel 2.2.2 → 2.2.4
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/DBModel.d.ts.map +1 -1
- package/dist/DBModel.js +3 -0
- package/dist/DBModel.js.map +1 -1
- package/dist/Middleware.d.ts +19 -2
- package/dist/Middleware.d.ts.map +1 -1
- package/dist/Middleware.js +1 -0
- package/dist/Middleware.js.map +1 -1
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +8 -0
- package/dist/decorators.js.map +1 -1
- package/dist/drivers/MysqlHelper.d.ts +1 -1
- package/dist/drivers/MysqlHelper.d.ts.map +1 -1
- package/dist/drivers/MysqlHelper.js.map +1 -1
- package/dist/drivers/PostgresHelper.d.ts +1 -1
- package/dist/drivers/PostgresHelper.d.ts.map +1 -1
- package/dist/drivers/PostgresHelper.js.map +1 -1
- package/dist/drivers/SqliteHelper.d.ts +1 -1
- package/dist/drivers/SqliteHelper.d.ts.map +1 -1
- package/dist/drivers/SqliteHelper.js.map +1 -1
- package/dist/index.cjs +105 -74
- package/dist/scp/connection-routing.d.ts +38 -1
- package/dist/scp/connection-routing.d.ts.map +1 -1
- package/dist/scp/connection-routing.js +64 -5
- package/dist/scp/connection-routing.js.map +1 -1
- package/dist/scp/dbmodel-runtime.d.ts +2 -1
- package/dist/scp/dbmodel-runtime.d.ts.map +1 -1
- package/dist/scp/dbmodel-runtime.js +2 -1
- package/dist/scp/dbmodel-runtime.js.map +1 -1
- package/dist/scp/decorator-adapter.d.ts +22 -0
- package/dist/scp/decorator-adapter.d.ts.map +1 -1
- package/dist/scp/decorator-adapter.js +26 -0
- package/dist/scp/decorator-adapter.js.map +1 -1
- package/dist/scp/emit/emitter.d.ts +21 -10
- package/dist/scp/emit/emitter.d.ts.map +1 -1
- package/dist/scp/emit/emitter.js +119 -51
- package/dist/scp/emit/emitter.js.map +1 -1
- package/dist/scp/emit/endpoint.d.ts +3 -8
- package/dist/scp/emit/endpoint.d.ts.map +1 -1
- package/dist/scp/exec-context.d.ts +39 -17
- package/dist/scp/exec-context.d.ts.map +1 -1
- package/dist/scp/exec-context.js +69 -35
- package/dist/scp/exec-context.js.map +1 -1
- package/dist/scp/grouping.d.ts.map +1 -1
- package/dist/scp/grouping.js +0 -0
- package/dist/scp/grouping.js.map +1 -1
- package/dist/scp/index.cjs +257 -670
- package/dist/scp/index.d.ts +6 -11
- package/dist/scp/index.d.ts.map +1 -1
- package/dist/scp/index.js +10 -28
- package/dist/scp/index.js.map +1 -1
- package/dist/scp/index.mjs +257 -658
- package/dist/scp/leaf-transport.d.ts +127 -39
- package/dist/scp/leaf-transport.d.ts.map +1 -1
- package/dist/scp/leaf-transport.js +30 -24
- package/dist/scp/leaf-transport.js.map +1 -1
- package/dist/scp/leaves.d.ts +57 -20
- package/dist/scp/leaves.d.ts.map +1 -1
- package/dist/scp/leaves.js +224 -65
- package/dist/scp/leaves.js.map +1 -1
- package/dist/scp/makesql/compile-select.d.ts +28 -1
- package/dist/scp/makesql/compile-select.d.ts.map +1 -1
- package/dist/scp/makesql/compile-select.js +19 -17
- package/dist/scp/makesql/compile-select.js.map +1 -1
- package/dist/scp/makesql/index.d.ts +2 -2
- package/dist/scp/makesql/index.d.ts.map +1 -1
- package/dist/scp/makesql/index.js +4 -6
- package/dist/scp/makesql/index.js.map +1 -1
- package/dist/scp/makesql/tx.d.ts +43 -89
- package/dist/scp/makesql/tx.d.ts.map +1 -1
- package/dist/scp/makesql/tx.js +45 -496
- package/dist/scp/makesql/tx.js.map +1 -1
- package/dist/scp/makesql/writeouttype.d.ts +5 -7
- package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
- package/dist/scp/makesql/writeouttype.js +13 -19
- package/dist/scp/makesql/writeouttype.js.map +1 -1
- package/dist/scp/middleware.d.ts +4 -4
- package/dist/scp/middleware.d.ts.map +1 -1
- package/dist/scp/middleware.js +2 -2
- package/dist/scp/middleware.js.map +1 -1
- package/dist/scp/relation.d.ts +31 -12
- package/dist/scp/relation.d.ts.map +1 -1
- package/dist/scp/relation.js +16 -6
- package/dist/scp/relation.js.map +1 -1
- package/dist/scp/typed-object.d.ts +23 -19
- package/dist/scp/typed-object.d.ts.map +1 -1
- package/dist/scp/typed-object.js +24 -30
- package/dist/scp/typed-object.js.map +1 -1
- package/dist/scp/write-bundle.d.ts +21 -70
- package/dist/scp/write-bundle.d.ts.map +1 -1
- package/dist/scp/write-bundle.js +16 -80
- package/dist/scp/write-bundle.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/docs/BENCHMARK.md +26 -22
- package/docs/COMPARISON.md +8 -4
- package/docs/api/README.md +1 -1
- package/docs/api/classes/Conditions.md +10 -10
- package/docs/api/classes/DBHandler.md +17 -17
- package/docs/api/classes/DBModel.md +111 -104
- package/docs/api/classes/LimitExceededError.md +8 -8
- package/docs/api/classes/Middleware.md +18 -18
- package/docs/api/classes/SqlRaw.md +6 -6
- package/docs/api/classes/SqlRef.md +7 -7
- package/docs/api/classes/Values.md +6 -6
- package/docs/api/classes/WriteInReadOnlyContextError.md +5 -5
- package/docs/api/classes/WriteOutsideTransactionError.md +5 -5
- package/docs/api/functions/belongsTo.md +2 -2
- package/docs/api/functions/closeAllPools.md +2 -2
- package/docs/api/functions/condsToRecord.md +2 -2
- package/docs/api/functions/createMiddleware.md +2 -2
- package/docs/api/functions/createPostgresDriver.md +2 -2
- package/docs/api/functions/createSqliteDriver.md +2 -2
- package/docs/api/functions/dbCast.md +3 -3
- package/docs/api/functions/dbCastIn.md +2 -2
- package/docs/api/functions/dbDynamic.md +3 -3
- package/docs/api/functions/dbFalse.md +2 -2
- package/docs/api/functions/dbImmediate.md +2 -2
- package/docs/api/functions/dbIn.md +2 -2
- package/docs/api/functions/dbNotNull.md +2 -2
- package/docs/api/functions/dbNow.md +2 -2
- package/docs/api/functions/dbNull.md +2 -2
- package/docs/api/functions/dbRaw.md +2 -2
- package/docs/api/functions/dbTrue.md +2 -2
- package/docs/api/functions/dbUuid.md +3 -3
- package/docs/api/functions/dbUuidIn.md +2 -2
- package/docs/api/functions/formatLocalDate.md +25 -0
- package/docs/api/functions/formatUTCDate.md +25 -0
- package/docs/api/functions/getDBConfig.md +2 -2
- package/docs/api/functions/getDBHandler.md +2 -2
- 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 +2 -2
- package/docs/api/functions/isAnySqlFragment.md +2 -2
- package/docs/api/functions/isConnectionError.md +26 -0
- package/docs/api/functions/isSqlCondition.md +2 -2
- package/docs/api/functions/isSqlFragment.md +2 -2
- package/docs/api/functions/isSqlRaw.md +2 -2
- package/docs/api/functions/isSqlRef.md +2 -2
- package/docs/api/functions/isSqlTypedFragment.md +2 -2
- package/docs/api/functions/model.md +6 -42
- package/docs/api/functions/parentRef.md +2 -2
- package/docs/api/functions/sql.md +7 -7
- package/docs/api/globals.md +57 -22
- package/docs/api/interfaces/Column.md +31 -31
- package/docs/api/interfaces/ColumnOptions.md +5 -4
- package/docs/api/interfaces/CreatedMiddlewareClass.md +7 -7
- package/docs/api/interfaces/DBConfig.md +13 -11
- package/docs/api/interfaces/DBConfigOptions.md +8 -8
- package/docs/api/interfaces/DeleteOptions.md +4 -4
- package/docs/api/interfaces/InsertOptions.md +8 -8
- package/docs/api/interfaces/LimitConfig.md +4 -4
- package/docs/api/interfaces/MiddlewareConfig.md +15 -15
- package/docs/api/interfaces/ModelOptions.md +8 -7
- package/docs/api/interfaces/PkeyResult.md +4 -4
- package/docs/api/interfaces/SelectOptions.md +17 -16
- package/docs/api/interfaces/SqlCondition.md +6 -6
- package/docs/api/interfaces/SqlFragment.md +5 -5
- package/docs/api/interfaces/SqlTypedFragment.md +7 -7
- package/docs/api/interfaces/TransactionOptions.md +7 -7
- package/docs/api/interfaces/UpdateManyOptions.md +4 -4
- package/docs/api/interfaces/UpdateOptions.md +4 -4
- package/docs/architecture.md +452 -0
- package/docs/benchmark-chart.svg +225 -249
- package/docs/design/phase-a-execution-context.md +2 -0
- package/package.json +20 -5
- package/dist/scp/writes.d.ts +0 -251
- package/dist/scp/writes.d.ts.map +0 -1
- package/dist/scp/writes.js +0 -176
- package/dist/scp/writes.js.map +0 -1
- package/docs/proposal/contracts-architecture-feasibility.md +0 -328
- package/docs/proposal/contracts-architecture.md +0 -579
- package/docs/proposal/litedbmodel-v2-scp-architecture.md +0 -433
- package/docs/proposal/sql-dynamic-expansion-spec.md +0 -175
- package/docs/proposal/v0-coverage-matrix.md +0 -157
- package/docs/proposal/v2-completeness-plan.md +0 -90
- package/docs/proposal/v2-sql-parity-checklist.md +0 -162
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: Column()\<ValueType, ModelType\>
|
|
8
8
|
|
|
9
|
-
Defined in: Column.ts:144
|
|
9
|
+
Defined in: [Column.ts:144](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L144)
|
|
10
10
|
|
|
11
11
|
Type-safe column reference as a callable function.
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ Type-safe column reference as a callable function.
|
|
|
21
21
|
Column(): string;
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Defined in: Column.ts:146
|
|
24
|
+
Defined in: [Column.ts:146](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L146)
|
|
25
25
|
|
|
26
26
|
Call to get column name as string (for computed property keys)
|
|
27
27
|
|
|
@@ -33,13 +33,13 @@ Call to get column name as string (for computed property keys)
|
|
|
33
33
|
|
|
34
34
|
| Property | Modifier | Type | Description | Defined in |
|
|
35
35
|
| ------ | ------ | ------ | ------ | ------ |
|
|
36
|
-
| <a id="columnname"></a> `columnName` | `readonly` | `string` | The database column name | Column.ts:149 |
|
|
37
|
-
| <a id="propertyname"></a> `propertyName` | `readonly` | `string` | The property name on the model class (may differ from columnName) | Column.ts:152 |
|
|
38
|
-
| <a id="tablename"></a> `tableName` | `readonly` | `string` | The database table name | Column.ts:155 |
|
|
39
|
-
| <a id="modelname"></a> `modelName` | `readonly` | `string` | The model class name (for debugging and static analysis) | Column.ts:158 |
|
|
40
|
-
| <a id="_brand"></a> `_brand` | `readonly` | `"Column"` | Brand for type discrimination - enables static analysis to distinguish from regular variables | Column.ts:161 |
|
|
41
|
-
| <a id="sqlcast"></a> `sqlCast?` | `readonly` | `string` | SQL type for automatic casting in conditions (e.g., 'uuid') | Column.ts:164 |
|
|
42
|
-
| <a id="__model"></a> `__model?` | `readonly` | `ModelType` | Phantom type for model association (compile-time only, not used at runtime) | Column.ts:167 |
|
|
36
|
+
| <a id="columnname"></a> `columnName` | `readonly` | `string` | The database column name | [Column.ts:149](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L149) |
|
|
37
|
+
| <a id="propertyname"></a> `propertyName` | `readonly` | `string` | The property name on the model class (may differ from columnName) | [Column.ts:152](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L152) |
|
|
38
|
+
| <a id="tablename"></a> `tableName` | `readonly` | `string` | The database table name | [Column.ts:155](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L155) |
|
|
39
|
+
| <a id="modelname"></a> `modelName` | `readonly` | `string` | The model class name (for debugging and static analysis) | [Column.ts:158](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L158) |
|
|
40
|
+
| <a id="_brand"></a> `_brand` | `readonly` | `"Column"` | Brand for type discrimination - enables static analysis to distinguish from regular variables | [Column.ts:161](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L161) |
|
|
41
|
+
| <a id="sqlcast"></a> `sqlCast?` | `readonly` | `string` | SQL type for automatic casting in conditions (e.g., 'uuid') | [Column.ts:164](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L164) |
|
|
42
|
+
| <a id="__model"></a> `__model?` | `readonly` | `ModelType` | Phantom type for model association (compile-time only, not used at runtime) | [Column.ts:167](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L167) |
|
|
43
43
|
|
|
44
44
|
## Methods
|
|
45
45
|
|
|
@@ -49,7 +49,7 @@ Call to get column name as string (for computed property keys)
|
|
|
49
49
|
eq(value: ValueType): Record<string, ValueType | DBCast>;
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
Defined in: Column.ts:177
|
|
52
|
+
Defined in: [Column.ts:177](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L177)
|
|
53
53
|
|
|
54
54
|
Equal condition (column = value)
|
|
55
55
|
|
|
@@ -77,7 +77,7 @@ User.id.eq(1) → { id: 1 }
|
|
|
77
77
|
ne(value: ValueType): Record<string, ValueType | DBCast>;
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
Defined in: Column.ts:183
|
|
80
|
+
Defined in: [Column.ts:183](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L183)
|
|
81
81
|
|
|
82
82
|
Not equal condition (column != value)
|
|
83
83
|
|
|
@@ -105,7 +105,7 @@ User.status.ne('deleted') → { 'status != ?': 'deleted' }
|
|
|
105
105
|
gt(value: ValueType): Record<string, ValueType | DBCast>;
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Defined in: Column.ts:189
|
|
108
|
+
Defined in: [Column.ts:189](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L189)
|
|
109
109
|
|
|
110
110
|
Greater than condition (column > value)
|
|
111
111
|
|
|
@@ -133,7 +133,7 @@ User.age.gt(18) → { 'age > ?': 18 }
|
|
|
133
133
|
gte(value: ValueType): Record<string, ValueType | DBCast>;
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
Defined in: Column.ts:195
|
|
136
|
+
Defined in: [Column.ts:195](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L195)
|
|
137
137
|
|
|
138
138
|
Greater than or equal condition (column >= value)
|
|
139
139
|
|
|
@@ -161,7 +161,7 @@ User.age.gte(18) → { 'age >= ?': 18 }
|
|
|
161
161
|
lt(value: ValueType): Record<string, ValueType | DBCast>;
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
Defined in: Column.ts:201
|
|
164
|
+
Defined in: [Column.ts:201](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L201)
|
|
165
165
|
|
|
166
166
|
Less than condition (column < value)
|
|
167
167
|
|
|
@@ -189,7 +189,7 @@ User.age.lt(65) → { 'age < ?': 65 }
|
|
|
189
189
|
lte(value: ValueType): Record<string, ValueType | DBCast>;
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
Defined in: Column.ts:207
|
|
192
|
+
Defined in: [Column.ts:207](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L207)
|
|
193
193
|
|
|
194
194
|
Less than or equal condition (column <= value)
|
|
195
195
|
|
|
@@ -217,7 +217,7 @@ User.age.lte(65) → { 'age <= ?': 65 }
|
|
|
217
217
|
like(pattern: string): Record<string, string>;
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
Defined in: Column.ts:213
|
|
220
|
+
Defined in: [Column.ts:213](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L213)
|
|
221
221
|
|
|
222
222
|
LIKE condition (column LIKE pattern)
|
|
223
223
|
|
|
@@ -245,7 +245,7 @@ User.name.like('%test%') → { 'name LIKE ?': '%test%' }
|
|
|
245
245
|
notLike(pattern: string): Record<string, string>;
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
Defined in: Column.ts:219
|
|
248
|
+
Defined in: [Column.ts:219](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L219)
|
|
249
249
|
|
|
250
250
|
NOT LIKE condition (column NOT LIKE pattern)
|
|
251
251
|
|
|
@@ -273,7 +273,7 @@ User.name.notLike('%test%') → { 'name NOT LIKE ?': '%test%' }
|
|
|
273
273
|
ilike(pattern: string): Record<string, string>;
|
|
274
274
|
```
|
|
275
275
|
|
|
276
|
-
Defined in: Column.ts:225
|
|
276
|
+
Defined in: [Column.ts:225](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L225)
|
|
277
277
|
|
|
278
278
|
ILIKE condition (case-insensitive LIKE, PostgreSQL specific)
|
|
279
279
|
|
|
@@ -301,7 +301,7 @@ User.name.ilike('%TEST%') → { 'name ILIKE ?': '%TEST%' }
|
|
|
301
301
|
between(from: ValueType, to: ValueType): Record<string, [ValueType, ValueType]>;
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
Defined in: Column.ts:231
|
|
304
|
+
Defined in: [Column.ts:231](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L231)
|
|
305
305
|
|
|
306
306
|
BETWEEN condition (column BETWEEN from AND to)
|
|
307
307
|
|
|
@@ -330,7 +330,7 @@ User.age.between(18, 65) → { 'age BETWEEN ? AND ?': [18, 65] }
|
|
|
330
330
|
in(values: ValueType[]): Record<string, ValueType[] | DBCastArray>;
|
|
331
331
|
```
|
|
332
332
|
|
|
333
|
-
Defined in: Column.ts:238
|
|
333
|
+
Defined in: [Column.ts:238](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L238)
|
|
334
334
|
|
|
335
335
|
IN condition (column IN (values))
|
|
336
336
|
Note: Arrays are automatically converted to IN clause by litedbmodel
|
|
@@ -359,7 +359,7 @@ User.status.in(['active', 'pending']) → { status: ['active', 'pending'] }
|
|
|
359
359
|
notIn(values: ValueType[]): Record<string, ValueType[] | DBCastArray>;
|
|
360
360
|
```
|
|
361
361
|
|
|
362
|
-
Defined in: Column.ts:244
|
|
362
|
+
Defined in: [Column.ts:244](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L244)
|
|
363
363
|
|
|
364
364
|
NOT IN condition (column NOT IN (values))
|
|
365
365
|
|
|
@@ -387,7 +387,7 @@ User.status.notIn(['deleted', 'banned'])
|
|
|
387
387
|
isNull(): Record<string, null>;
|
|
388
388
|
```
|
|
389
389
|
|
|
390
|
-
Defined in: Column.ts:250
|
|
390
|
+
Defined in: [Column.ts:250](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L250)
|
|
391
391
|
|
|
392
392
|
IS NULL condition
|
|
393
393
|
|
|
@@ -409,7 +409,7 @@ User.deleted_at.isNull() → { deleted_at: null }
|
|
|
409
409
|
isNotNull(): Record<string, DBNotNullValue>;
|
|
410
410
|
```
|
|
411
411
|
|
|
412
|
-
Defined in: Column.ts:256
|
|
412
|
+
Defined in: [Column.ts:256](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L256)
|
|
413
413
|
|
|
414
414
|
IS NOT NULL condition
|
|
415
415
|
|
|
@@ -431,7 +431,7 @@ User.email.isNotNull() → { email: DBNotNullValue }
|
|
|
431
431
|
asc(): OrderColumn<ModelType>;
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
-
Defined in: Column.ts:266
|
|
434
|
+
Defined in: [Column.ts:266](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L266)
|
|
435
435
|
|
|
436
436
|
Ascending order
|
|
437
437
|
|
|
@@ -453,7 +453,7 @@ User.created_at.asc() → OrderColumn('created_at', 'ASC')
|
|
|
453
453
|
desc(): OrderColumn<ModelType>;
|
|
454
454
|
```
|
|
455
455
|
|
|
456
|
-
Defined in: Column.ts:272
|
|
456
|
+
Defined in: [Column.ts:272](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L272)
|
|
457
457
|
|
|
458
458
|
Descending order
|
|
459
459
|
|
|
@@ -475,7 +475,7 @@ User.created_at.desc() → OrderColumn('created_at', 'DESC')
|
|
|
475
475
|
ascNullsFirst(): OrderColumn<ModelType>;
|
|
476
476
|
```
|
|
477
477
|
|
|
478
|
-
Defined in: Column.ts:278
|
|
478
|
+
Defined in: [Column.ts:278](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L278)
|
|
479
479
|
|
|
480
480
|
Ascending order with NULLS FIRST
|
|
481
481
|
|
|
@@ -497,7 +497,7 @@ User.updated_at.ascNullsFirst() → OrderColumn with NULLS FIRST
|
|
|
497
497
|
ascNullsLast(): OrderColumn<ModelType>;
|
|
498
498
|
```
|
|
499
499
|
|
|
500
|
-
Defined in: Column.ts:284
|
|
500
|
+
Defined in: [Column.ts:284](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L284)
|
|
501
501
|
|
|
502
502
|
Ascending order with NULLS LAST
|
|
503
503
|
|
|
@@ -519,7 +519,7 @@ User.updated_at.ascNullsLast() → OrderColumn with NULLS LAST
|
|
|
519
519
|
descNullsFirst(): OrderColumn<ModelType>;
|
|
520
520
|
```
|
|
521
521
|
|
|
522
|
-
Defined in: Column.ts:290
|
|
522
|
+
Defined in: [Column.ts:290](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L290)
|
|
523
523
|
|
|
524
524
|
Descending order with NULLS FIRST
|
|
525
525
|
|
|
@@ -541,7 +541,7 @@ User.updated_at.descNullsFirst() → OrderColumn with NULLS FIRST
|
|
|
541
541
|
descNullsLast(): OrderColumn<ModelType>;
|
|
542
542
|
```
|
|
543
543
|
|
|
544
|
-
Defined in: Column.ts:296
|
|
544
|
+
Defined in: [Column.ts:296](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L296)
|
|
545
545
|
|
|
546
546
|
Descending order with NULLS LAST
|
|
547
547
|
|
|
@@ -563,7 +563,7 @@ User.updated_at.descNullsLast() → OrderColumn with NULLS LAST
|
|
|
563
563
|
toString(): string;
|
|
564
564
|
```
|
|
565
565
|
|
|
566
|
-
Defined in: Column.ts:306
|
|
566
|
+
Defined in: [Column.ts:306](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L306)
|
|
567
567
|
|
|
568
568
|
Returns column name (for template literals)
|
|
569
569
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: ColumnOptions
|
|
8
8
|
|
|
9
|
-
Defined in: decorators.ts:
|
|
9
|
+
Defined in: [decorators.ts:348](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L348)
|
|
10
10
|
|
|
11
11
|
Options that can be passed to
|
|
12
12
|
|
|
@@ -18,5 +18,6 @@ decorator
|
|
|
18
18
|
|
|
19
19
|
| Property | Type | Description | Defined in |
|
|
20
20
|
| ------ | ------ | ------ | ------ |
|
|
21
|
-
| <a id="columnname"></a> `columnName?` | `string` | Custom column name (defaults to property name) | decorators.ts:
|
|
22
|
-
| <a id="primarykey"></a> `primaryKey?` | `boolean` | Mark this column as part of the primary key | decorators.ts:
|
|
21
|
+
| <a id="columnname"></a> `columnName?` | `string` | Custom column name (defaults to property name) | [decorators.ts:350](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L350) |
|
|
22
|
+
| <a id="primarykey"></a> `primaryKey?` | `boolean` | Mark this column as part of the primary key | [decorators.ts:352](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L352) |
|
|
23
|
+
| <a id="autoincrement"></a> `autoIncrement?` | `boolean` | The SERVER assigns this column's value (`AUTO_INCREMENT` / `SERIAL` / `IDENTITY`) — a write does not supply it. Declare it on an auto-increment primary key so a `RETURNING` write can recover the rows it wrote on a dialect that has no native `RETURNING`. See ColumnMeta.autoIncrement. | [decorators.ts:358](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L358) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: CreatedMiddlewareClass\<S\>
|
|
8
8
|
|
|
9
|
-
Defined in: Middleware.ts:
|
|
9
|
+
Defined in: [Middleware.ts:442](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L442)
|
|
10
10
|
|
|
11
11
|
Type for the middleware class created by createMiddleware.
|
|
12
12
|
Provides typed access to state via getCurrentContext().
|
|
@@ -25,7 +25,7 @@ Provides typed access to state via getCurrentContext().
|
|
|
25
25
|
new CreatedMiddlewareClass(): Middleware & S;
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
Defined in: Middleware.ts:
|
|
28
|
+
Defined in: [Middleware.ts:452](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L452)
|
|
29
29
|
|
|
30
30
|
Constructor
|
|
31
31
|
|
|
@@ -41,7 +41,7 @@ Constructor
|
|
|
41
41
|
getCurrentContext(): S;
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Defined in: Middleware.ts:
|
|
44
|
+
Defined in: [Middleware.ts:444](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L444)
|
|
45
45
|
|
|
46
46
|
Get the current request's state (creates new instance if none exists)
|
|
47
47
|
|
|
@@ -57,7 +57,7 @@ Get the current request's state (creates new instance if none exists)
|
|
|
57
57
|
run<R>(fn: () => R): R;
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Defined in: Middleware.ts:
|
|
60
|
+
Defined in: [Middleware.ts:446](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L446)
|
|
61
61
|
|
|
62
62
|
Run a function with a fresh middleware context
|
|
63
63
|
|
|
@@ -85,7 +85,7 @@ Run a function with a fresh middleware context
|
|
|
85
85
|
hasContext(): boolean;
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
Defined in: Middleware.ts:
|
|
88
|
+
Defined in: [Middleware.ts:448](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L448)
|
|
89
89
|
|
|
90
90
|
Check if a context exists for the current request
|
|
91
91
|
|
|
@@ -101,7 +101,7 @@ Check if a context exists for the current request
|
|
|
101
101
|
clearContext(): void;
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
Defined in: Middleware.ts:
|
|
104
|
+
Defined in: [Middleware.ts:450](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L450)
|
|
105
105
|
|
|
106
106
|
Clear the current context (useful for testing)
|
|
107
107
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: DBConfig
|
|
8
8
|
|
|
9
|
-
Defined in: DBHandler.ts:
|
|
9
|
+
Defined in: [DBHandler.ts:41](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L41)
|
|
10
10
|
|
|
11
11
|
Database configuration
|
|
12
12
|
|
|
@@ -14,12 +14,14 @@ Database configuration
|
|
|
14
14
|
|
|
15
15
|
| Property | Type | Description | Defined in |
|
|
16
16
|
| ------ | ------ | ------ | ------ |
|
|
17
|
-
| <a id="host"></a> `host?` | `string` | Database host (for server-based DBs) | DBHandler.ts:
|
|
18
|
-
| <a id="port"></a> `port?` | `number` | Database port | DBHandler.ts:
|
|
19
|
-
| <a id="database"></a> `database` | `string` | Database name or file path | DBHandler.ts:
|
|
20
|
-
| <a id="user"></a> `user?` | `string` | Username | DBHandler.ts:
|
|
21
|
-
| <a id="password"></a> `password?` | `string` | Password | DBHandler.ts:
|
|
22
|
-
| <a id="max"></a> `max?` | `number` | Maximum pool size | DBHandler.ts:
|
|
23
|
-
| <a id="timeout"></a> `timeout?` | `number` | Connection timeout in seconds | DBHandler.ts:
|
|
24
|
-
| <a id="querytimeout"></a> `queryTimeout?` | `number` | Query timeout in seconds | DBHandler.ts:
|
|
25
|
-
| <a id="
|
|
17
|
+
| <a id="host"></a> `host?` | `string` | Database host (for server-based DBs) | [DBHandler.ts:43](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L43) |
|
|
18
|
+
| <a id="port"></a> `port?` | `number` | Database port | [DBHandler.ts:45](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L45) |
|
|
19
|
+
| <a id="database"></a> `database` | `string` | Database name or file path | [DBHandler.ts:47](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L47) |
|
|
20
|
+
| <a id="user"></a> `user?` | `string` | Username | [DBHandler.ts:49](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L49) |
|
|
21
|
+
| <a id="password"></a> `password?` | `string` | Password | [DBHandler.ts:51](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L51) |
|
|
22
|
+
| <a id="max"></a> `max?` | `number` | Maximum pool size | [DBHandler.ts:53](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L53) |
|
|
23
|
+
| <a id="timeout"></a> `timeout?` | `number` | Connection timeout in seconds | [DBHandler.ts:55](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L55) |
|
|
24
|
+
| <a id="querytimeout"></a> `queryTimeout?` | `number` | Query timeout in seconds | [DBHandler.ts:57](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L57) |
|
|
25
|
+
| <a id="keepalive"></a> `keepAlive?` | `boolean` | Enable TCP keepalive on connections (recommended for serverless/Lambda) | [DBHandler.ts:59](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L59) |
|
|
26
|
+
| <a id="keepaliveinitialdelaymillis"></a> `keepAliveInitialDelayMillis?` | `number` | Delay in milliseconds before first keepalive probe (default: 10000) | [DBHandler.ts:61](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L61) |
|
|
27
|
+
| <a id="driver"></a> `driver?` | `"postgres"` \| `"mysql"` \| `"sqlite"` | Driver type: 'postgres' (default), 'sqlite', or 'mysql' | [DBHandler.ts:63](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L63) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: DBConfigOptions
|
|
8
8
|
|
|
9
|
-
Defined in: types.ts:
|
|
9
|
+
Defined in: [types.ts:290](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L290)
|
|
10
10
|
|
|
11
11
|
Options for database configuration.
|
|
12
12
|
Used with DBModel.setConfig() and DBModel.createDBBase().
|
|
@@ -15,9 +15,9 @@ Used with DBModel.setConfig() and DBModel.createDBBase().
|
|
|
15
15
|
|
|
16
16
|
| Property | Type | Description | Defined in |
|
|
17
17
|
| ------ | ------ | ------ | ------ |
|
|
18
|
-
| <a id="writerconfig"></a> `writerConfig?` | `DBConfig` | Writer database configuration for reader/writer separation | types.ts:
|
|
19
|
-
| <a id="logger"></a> `logger?` | `Logger` | Logger instance | types.ts:
|
|
20
|
-
| <a id="findhardlimit"></a> `findHardLimit?` | `number` \| `null` | Hard limit for find() - throws if exceeded | types.ts:
|
|
21
|
-
| <a id="hasmanyhardlimit"></a> `hasManyHardLimit?` | `number` \| `null` | Hard limit for hasMany lazy loading - throws if exceeded | types.ts:
|
|
22
|
-
| <a id="usewriteraftertransaction"></a> `useWriterAfterTransaction?` | `boolean` | Keep using writer connection after transaction completes. Helps avoid stale reads due to replication lag. **Default** `true` | types.ts:
|
|
23
|
-
| <a id="writerstickyduration"></a> `writerStickyDuration?` | `number` | Duration (in milliseconds) to keep using writer after transaction. Only applies when useWriterAfterTransaction is true. **Default** `5000` | types.ts:
|
|
18
|
+
| <a id="writerconfig"></a> `writerConfig?` | `DBConfig` | Writer database configuration for reader/writer separation | [types.ts:292](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L292) |
|
|
19
|
+
| <a id="logger"></a> `logger?` | `Logger` | Logger instance | [types.ts:294](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L294) |
|
|
20
|
+
| <a id="findhardlimit"></a> `findHardLimit?` | `number` \| `null` | Hard limit for find() - throws if exceeded | [types.ts:296](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L296) |
|
|
21
|
+
| <a id="hasmanyhardlimit"></a> `hasManyHardLimit?` | `number` \| `null` | Hard limit for hasMany lazy loading - throws if exceeded | [types.ts:298](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L298) |
|
|
22
|
+
| <a id="usewriteraftertransaction"></a> `useWriterAfterTransaction?` | `boolean` | Keep using writer connection after transaction completes. Helps avoid stale reads due to replication lag. **Default** `true` | [types.ts:304](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L304) |
|
|
23
|
+
| <a id="writerstickyduration"></a> `writerStickyDuration?` | `number` | Duration (in milliseconds) to keep using writer after transaction. Only applies when useWriterAfterTransaction is true. **Default** `5000` | [types.ts:310](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L310) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: DeleteOptions
|
|
8
8
|
|
|
9
|
-
Defined in: types.ts:
|
|
9
|
+
Defined in: [types.ts:222](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L222)
|
|
10
10
|
|
|
11
11
|
## Properties
|
|
12
12
|
|
|
13
13
|
| Property | Type | Description | Defined in |
|
|
14
14
|
| ------ | ------ | ------ | ------ |
|
|
15
|
-
| <a id="tablename"></a> `tableName?` | `string` | - | types.ts:
|
|
16
|
-
| <a id="returning"></a> `returning?` | `boolean` | If true, return PkeyResult with affected primary keys. If false (default), return null for better performance. | types.ts:
|
|
15
|
+
| <a id="tablename"></a> `tableName?` | `string` | - | [types.ts:223](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L223) |
|
|
16
|
+
| <a id="returning"></a> `returning?` | `boolean` | If true, return PkeyResult with affected primary keys. If false (default), return null for better performance. | [types.ts:228](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L228) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: InsertOptions\<Model\>
|
|
8
8
|
|
|
9
|
-
Defined in: types.ts:
|
|
9
|
+
Defined in: [types.ts:175](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L175)
|
|
10
10
|
|
|
11
11
|
Insert options with type-safe column references.
|
|
12
12
|
|
|
@@ -20,9 +20,9 @@ Insert options with type-safe column references.
|
|
|
20
20
|
|
|
21
21
|
| Property | Type | Description | Defined in |
|
|
22
22
|
| ------ | ------ | ------ | ------ |
|
|
23
|
-
| <a id="tablename"></a> `tableName?` | `string` | - | types.ts:
|
|
24
|
-
| <a id="returning"></a> `returning?` | `boolean` | If true, return PkeyResult with affected primary keys. If false (default), return null for better performance. | types.ts:
|
|
25
|
-
| <a id="conflict"></a> ~~`conflict?`~~ | `string` | **Deprecated** Use onConflict instead | types.ts:
|
|
26
|
-
| <a id="onconflict"></a> `onConflict?` | \| [`Column`](Column.md)\<`unknown`, `Model`\> \| [`Column`](Column.md)\<`unknown`, `Model`\>[] | Columns for ON CONFLICT clause (unique constraint columns). Must be Column symbols from the same model for type safety. **Example** `// Single column onConflict: User.email // Multiple columns (composite unique constraint) onConflict: [UserPref.user_id, UserPref.key]` | types.ts:
|
|
27
|
-
| <a id="onconflictupdate"></a> `onConflictUpdate?` | `"all"` \| [`Column`](Column.md)\<`unknown`, `Model`\>[] | Columns to update on conflict. Can be: - 'all': Update all inserted columns - Array of Column symbols from the same model **Example** `// Update all columns onConflictUpdate: 'all' // Update specific columns onConflictUpdate: [User.name, User.updated_at]` | types.ts:
|
|
28
|
-
| <a id="onconflictignore"></a> `onConflictIgnore?` | `boolean` | If true, ignore the insert on conflict (DO NOTHING). Cannot be used with onConflictUpdate. | types.ts:
|
|
23
|
+
| <a id="tablename"></a> `tableName?` | `string` | - | [types.ts:176](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L176) |
|
|
24
|
+
| <a id="returning"></a> `returning?` | `boolean` | If true, return PkeyResult with affected primary keys. If false (default), return null for better performance. | [types.ts:181](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L181) |
|
|
25
|
+
| <a id="conflict"></a> ~~`conflict?`~~ | `string` | **Deprecated** Use onConflict instead | [types.ts:183](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L183) |
|
|
26
|
+
| <a id="onconflict"></a> `onConflict?` | \| [`Column`](Column.md)\<`unknown`, `Model`\> \| [`Column`](Column.md)\<`unknown`, `Model`\>[] | Columns for ON CONFLICT clause (unique constraint columns). Must be Column symbols from the same model for type safety. **Example** `// Single column onConflict: User.email // Multiple columns (composite unique constraint) onConflict: [UserPref.user_id, UserPref.key]` | [types.ts:193](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L193) |
|
|
27
|
+
| <a id="onconflictupdate"></a> `onConflictUpdate?` | `"all"` \| [`Column`](Column.md)\<`unknown`, `Model`\>[] | Columns to update on conflict. Can be: - 'all': Update all inserted columns - Array of Column symbols from the same model **Example** `// Update all columns onConflictUpdate: 'all' // Update specific columns onConflictUpdate: [User.name, User.updated_at]` | [types.ts:205](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L205) |
|
|
28
|
+
| <a id="onconflictignore"></a> `onConflictIgnore?` | `boolean` | If true, ignore the insert on conflict (DO NOTHING). Cannot be used with onConflictUpdate. | [types.ts:210](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L210) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: LimitConfig
|
|
8
8
|
|
|
9
|
-
Defined in: types.ts:
|
|
9
|
+
Defined in: [types.ts:345](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L345)
|
|
10
10
|
|
|
11
11
|
Configuration for query result limits.
|
|
12
12
|
Used to prevent accidentally loading too many records.
|
|
@@ -15,5 +15,5 @@ Used to prevent accidentally loading too many records.
|
|
|
15
15
|
|
|
16
16
|
| Property | Type | Description | Defined in |
|
|
17
17
|
| ------ | ------ | ------ | ------ |
|
|
18
|
-
| <a id="findhardlimit"></a> `findHardLimit?` | `number` \| `null` | Hard limit for find() queries. If a query returns more than this many records, an exception is thrown. Set to null to disable. **Default** `null (no limit)` | types.ts:
|
|
19
|
-
| <a id="hasmanyhardlimit"></a> `hasManyHardLimit?` | `number` \| `null` | Hard limit for hasMany relation loading (batch total). If a hasMany batch load returns more than this many records in total, an exception is thrown. Set to null to disable. **Default** `null (no limit)` | types.ts:
|
|
18
|
+
| <a id="findhardlimit"></a> `findHardLimit?` | `number` \| `null` | Hard limit for find() queries. If a query returns more than this many records, an exception is thrown. Set to null to disable. **Default** `null (no limit)` | [types.ts:352](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L352) |
|
|
19
|
+
| <a id="hasmanyhardlimit"></a> `hasManyHardLimit?` | `number` \| `null` | Hard limit for hasMany relation loading (batch total). If a hasMany batch load returns more than this many records in total, an exception is thrown. Set to null to disable. **Default** `null (no limit)` | [types.ts:361](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L361) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MiddlewareConfig\<S\>
|
|
8
8
|
|
|
9
|
-
Defined in: Middleware.ts:
|
|
9
|
+
Defined in: [Middleware.ts:326](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L326)
|
|
10
10
|
|
|
11
11
|
Configuration object for createMiddleware.
|
|
12
12
|
All hook functions receive `this` bound to the state object.
|
|
@@ -25,16 +25,16 @@ Hook signature matches the Middleware class:
|
|
|
25
25
|
|
|
26
26
|
| Property | Type | Description | Defined in |
|
|
27
27
|
| ------ | ------ | ------ | ------ |
|
|
28
|
-
| <a id="state"></a> `state?` | `S` | Initial state for each request context. A fresh copy is created for each request via structuredClone. Access via `this` in hook functions or `getCurrentContext()`. | Middleware.ts:
|
|
29
|
-
| <a id="init"></a> `init?` | (`this`: `S`) => `void` | Called when a new context is created | Middleware.ts:
|
|
30
|
-
| <a id="find"></a> `find?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextFind`\<`T`\>, `conditions`: `Conds`, `options?`: [`SelectOptions`](SelectOptions.md)) => `Promise`\<`InstanceType`\<`T`\>[]\> | Intercept find() | Middleware.ts:
|
|
31
|
-
| <a id="findone"></a> `findOne?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextFindOne`\<`T`\>, `conditions`: `Conds`, `options?`: [`SelectOptions`](SelectOptions.md)) => `Promise`\<`InstanceType`\<`T`\> \| `null`\> | Intercept findOne() | Middleware.ts:
|
|
32
|
-
| <a id="findbyid"></a> `findById?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextFindById`\<`T`\>, `id`: `unknown`, `options?`: [`SelectOptions`](SelectOptions.md)) => `Promise`\<`InstanceType`\<`T`\>[]\> | Intercept findById() | Middleware.ts:
|
|
33
|
-
| <a id="count"></a> `count?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextCount`, `conditions`: `Conds`) => `Promise`\<`number`\> | Intercept count() | Middleware.ts:
|
|
34
|
-
| <a id="create"></a> `create?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextCreate`, `pairs`: readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][], `options?`: [`InsertOptions`](InsertOptions.md)\<`unknown`\>) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept create() | Middleware.ts:
|
|
35
|
-
| <a id="createmany"></a> `createMany?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextCreateMany`, `pairsArray`: readonly readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][][], `options?`: [`InsertOptions`](InsertOptions.md)\<`unknown`\>) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept createMany() | Middleware.ts:
|
|
36
|
-
| <a id="update"></a> `update?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextUpdate`, `conditions`: `Conds`, `values`: readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][], `options?`: [`UpdateOptions`](UpdateOptions.md)) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept update() | Middleware.ts:
|
|
37
|
-
| <a id="updatemany"></a> `updateMany?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextUpdateMany`, `records`: readonly readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][][], `options?`: [`UpdateManyOptions`](UpdateManyOptions.md)) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept updateMany() | Middleware.ts:
|
|
38
|
-
| <a id="delete"></a> `delete?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextDelete`, `conditions`: `Conds`, `options?`: [`DeleteOptions`](DeleteOptions.md)) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept delete() | Middleware.ts:
|
|
39
|
-
| <a id="execute"></a> `execute?` | (`this`: `S`, `next`: `NextExecute`, `sql`: `string`, `params?`: `unknown`[]) => `Promise`\<`ExecuteResult`\> | Intercept execute() - lowest level, catches ALL SQL queries | Middleware.ts:
|
|
40
|
-
| <a id="query"></a> `query?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextQuery`\<`T`\>, `sql`: `string`, `params?`: `unknown`[]) => `Promise`\<`InstanceType`\<`T`\>[]\> | Intercept query() - catches raw SQL that returns model instances | Middleware.ts:
|
|
28
|
+
| <a id="state"></a> `state?` | `S` | Initial state for each request context. A fresh copy is created for each request via structuredClone. Access via `this` in hook functions or `getCurrentContext()`. | [Middleware.ts:332](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L332) |
|
|
29
|
+
| <a id="init"></a> `init?` | (`this`: `S`) => `void` | Called when a new context is created | [Middleware.ts:335](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L335) |
|
|
30
|
+
| <a id="find"></a> `find?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextFind`\<`T`\>, `conditions`: `Conds`, `options?`: [`SelectOptions`](SelectOptions.md)) => `Promise`\<`InstanceType`\<`T`\>[]\> | Intercept find() | [Middleware.ts:338](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L338) |
|
|
31
|
+
| <a id="findone"></a> `findOne?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextFindOne`\<`T`\>, `conditions`: `Conds`, `options?`: [`SelectOptions`](SelectOptions.md)) => `Promise`\<`InstanceType`\<`T`\> \| `null`\> | Intercept findOne() | [Middleware.ts:347](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L347) |
|
|
32
|
+
| <a id="findbyid"></a> `findById?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextFindById`\<`T`\>, `id`: `unknown`, `options?`: [`SelectOptions`](SelectOptions.md)) => `Promise`\<`InstanceType`\<`T`\>[]\> | Intercept findById() | [Middleware.ts:356](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L356) |
|
|
33
|
+
| <a id="count"></a> `count?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextCount`, `conditions`: `Conds`) => `Promise`\<`number`\> | Intercept count() | [Middleware.ts:365](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L365) |
|
|
34
|
+
| <a id="create"></a> `create?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextCreate`, `pairs`: readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][], `options?`: [`InsertOptions`](InsertOptions.md)\<`unknown`\>) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept create() | [Middleware.ts:373](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L373) |
|
|
35
|
+
| <a id="createmany"></a> `createMany?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextCreateMany`, `pairsArray`: readonly readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][][], `options?`: [`InsertOptions`](InsertOptions.md)\<`unknown`\>) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept createMany() | [Middleware.ts:382](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L382) |
|
|
36
|
+
| <a id="update"></a> `update?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextUpdate`, `conditions`: `Conds`, `values`: readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][], `options?`: [`UpdateOptions`](UpdateOptions.md)) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept update() | [Middleware.ts:391](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L391) |
|
|
37
|
+
| <a id="updatemany"></a> `updateMany?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextUpdateMany`, `records`: readonly readonly readonly \[[`Column`](Column.md)\<`any`, `any`\>, `any`\][][], `options?`: [`UpdateManyOptions`](UpdateManyOptions.md)) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept updateMany() | [Middleware.ts:401](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L401) |
|
|
38
|
+
| <a id="delete"></a> `delete?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextDelete`, `conditions`: `Conds`, `options?`: [`DeleteOptions`](DeleteOptions.md)) => `Promise`\<[`PkeyResult`](PkeyResult.md) \| `null`\> | Intercept delete() | [Middleware.ts:410](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L410) |
|
|
39
|
+
| <a id="execute"></a> `execute?` | (`this`: `S`, `next`: `NextExecute`, `sql`: `string`, `params?`: `unknown`[]) => `Promise`\<`ExecuteResult`\> | Intercept execute() - lowest level, catches ALL SQL queries | [Middleware.ts:419](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L419) |
|
|
40
|
+
| <a id="query"></a> `query?` | \<`T`\>(`this`: `S`, `model`: `T`, `next`: `NextQuery`\<`T`\>, `sql`: `string`, `params?`: `unknown`[]) => `Promise`\<`InstanceType`\<`T`\>[]\> | Intercept query() - catches raw SQL that returns model instances | [Middleware.ts:427](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L427) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: ModelOptions
|
|
8
8
|
|
|
9
|
-
Defined in: types.ts:43
|
|
9
|
+
Defined in: [types.ts:43](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L43)
|
|
10
10
|
|
|
11
11
|
Options for the
|
|
12
12
|
|
|
@@ -19,8 +19,9 @@ All options use lazy evaluation (functions) to support forward references.
|
|
|
19
19
|
|
|
20
20
|
| Property | Type | Description | Defined in |
|
|
21
21
|
| ------ | ------ | ------ | ------ |
|
|
22
|
-
| <a id="order"></a> `order?` | () => `OrderSpec` | DEFAULT_ORDER: Returns OrderSpec for default ordering | types.ts:45 |
|
|
23
|
-
| <a id="filter"></a> `filter?` | () => `Conds` | FIND_FILTER: Returns Conds for automatic filtering in find() | types.ts:48 |
|
|
24
|
-
| <a id="select"></a> `select?` | `string` | SELECT_COLUMN: Column selection string (default: '*') | types.ts:51 |
|
|
25
|
-
| <a id="updatetable"></a> `updateTable?` | `string` | UPDATE_TABLE_NAME: Table name for INSERT/UPDATE operations | types.ts:54 |
|
|
26
|
-
| <a id="group"></a> `group?` | () => \| `string` \| [`Column`](Column.md)\<`unknown`, `unknown`\> \| [`Column`](Column.md)\<`unknown`, `unknown`\>[] | DEFAULT_GROUP: Returns Column(s) or string for default grouping | types.ts:57 |
|
|
22
|
+
| <a id="order"></a> `order?` | () => `OrderSpec` | DEFAULT_ORDER: Returns OrderSpec for default ordering | [types.ts:45](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L45) |
|
|
23
|
+
| <a id="filter"></a> `filter?` | () => `Conds` | FIND_FILTER: Returns Conds for automatic filtering in find() | [types.ts:48](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L48) |
|
|
24
|
+
| <a id="select"></a> `select?` | `string` | SELECT_COLUMN: Column selection string (default: '*') | [types.ts:51](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L51) |
|
|
25
|
+
| <a id="updatetable"></a> `updateTable?` | `string` | UPDATE_TABLE_NAME: Table name for INSERT/UPDATE operations | [types.ts:54](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L54) |
|
|
26
|
+
| <a id="group"></a> `group?` | () => \| `string` \| [`Column`](Column.md)\<`unknown`, `unknown`\> \| [`Column`](Column.md)\<`unknown`, `unknown`\>[] | DEFAULT_GROUP: Returns Column(s) or string for default grouping | [types.ts:57](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L57) |
|
|
27
|
+
| <a id="connection"></a> `connection?` | `string` | CONNECTION: the NAME of the database this model lives in (multi-DB). Absent ⇒ the default connection. This is the SAME authority v1 gives the model — a v1 model picks its database by extending a `DBModel.createDBBase(config)` base class, whose handler owns the connection, and a relation is batch-loaded on the TARGET model's (`LazyRelation.ts:236` `TargetClass.getDriverType()`). Naming it makes that authority READABLE at emit time, which is what the codegen path needs: the emitter bakes the name onto every statement of every endpoint declared over this model, and onto the child fetch of every relation whose TARGET is this model, so a per-language runtime routes the statement to the pooled driver registered under it (`ConnectionRegistry`). Unregistered ⇒ LOUD, never a silent run against the wrong database. | [types.ts:70](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L70) |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v2.2.4**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: PkeyResult
|
|
8
8
|
|
|
9
|
-
Defined in: types.ts:26
|
|
9
|
+
Defined in: [types.ts:26](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L26)
|
|
10
10
|
|
|
11
11
|
Result of write operations when returning: true is specified.
|
|
12
12
|
Contains primary key column(s) and their values for affected rows.
|
|
@@ -25,5 +25,5 @@ Contains primary key column(s) and their values for affected rows.
|
|
|
25
25
|
|
|
26
26
|
| Property | Type | Description | Defined in |
|
|
27
27
|
| ------ | ------ | ------ | ------ |
|
|
28
|
-
| <a id="key"></a> `key` | [`Column`](Column.md)\<`unknown`, `unknown`\>[] | Primary key column(s) | types.ts:28 |
|
|
29
|
-
| <a id="values"></a> `values` | `unknown`[][] | 2D array of primary key values (each inner array is one row's PK values) | types.ts:30 |
|
|
28
|
+
| <a id="key"></a> `key` | [`Column`](Column.md)\<`unknown`, `unknown`\>[] | Primary key column(s) | [types.ts:28](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L28) |
|
|
29
|
+
| <a id="values"></a> `values` | `unknown`[][] | 2D array of primary key values (each inner array is one row's PK values) | [types.ts:30](https://github.com/foo-ogawa/litedbmodel/blob/main/src/types.ts#L30) |
|