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.
Files changed (180) hide show
  1. package/README.md +2 -1
  2. package/dist/DBModel.d.ts.map +1 -1
  3. package/dist/DBModel.js +3 -0
  4. package/dist/DBModel.js.map +1 -1
  5. package/dist/Middleware.d.ts +19 -2
  6. package/dist/Middleware.d.ts.map +1 -1
  7. package/dist/Middleware.js +1 -0
  8. package/dist/Middleware.js.map +1 -1
  9. package/dist/decorators.d.ts.map +1 -1
  10. package/dist/decorators.js +8 -0
  11. package/dist/decorators.js.map +1 -1
  12. package/dist/drivers/MysqlHelper.d.ts +1 -1
  13. package/dist/drivers/MysqlHelper.d.ts.map +1 -1
  14. package/dist/drivers/MysqlHelper.js.map +1 -1
  15. package/dist/drivers/PostgresHelper.d.ts +1 -1
  16. package/dist/drivers/PostgresHelper.d.ts.map +1 -1
  17. package/dist/drivers/PostgresHelper.js.map +1 -1
  18. package/dist/drivers/SqliteHelper.d.ts +1 -1
  19. package/dist/drivers/SqliteHelper.d.ts.map +1 -1
  20. package/dist/drivers/SqliteHelper.js.map +1 -1
  21. package/dist/index.cjs +105 -74
  22. package/dist/scp/connection-routing.d.ts +38 -1
  23. package/dist/scp/connection-routing.d.ts.map +1 -1
  24. package/dist/scp/connection-routing.js +64 -5
  25. package/dist/scp/connection-routing.js.map +1 -1
  26. package/dist/scp/dbmodel-runtime.d.ts +2 -1
  27. package/dist/scp/dbmodel-runtime.d.ts.map +1 -1
  28. package/dist/scp/dbmodel-runtime.js +2 -1
  29. package/dist/scp/dbmodel-runtime.js.map +1 -1
  30. package/dist/scp/decorator-adapter.d.ts +22 -0
  31. package/dist/scp/decorator-adapter.d.ts.map +1 -1
  32. package/dist/scp/decorator-adapter.js +26 -0
  33. package/dist/scp/decorator-adapter.js.map +1 -1
  34. package/dist/scp/emit/emitter.d.ts +21 -10
  35. package/dist/scp/emit/emitter.d.ts.map +1 -1
  36. package/dist/scp/emit/emitter.js +119 -51
  37. package/dist/scp/emit/emitter.js.map +1 -1
  38. package/dist/scp/emit/endpoint.d.ts +3 -8
  39. package/dist/scp/emit/endpoint.d.ts.map +1 -1
  40. package/dist/scp/exec-context.d.ts +39 -17
  41. package/dist/scp/exec-context.d.ts.map +1 -1
  42. package/dist/scp/exec-context.js +69 -35
  43. package/dist/scp/exec-context.js.map +1 -1
  44. package/dist/scp/grouping.d.ts.map +1 -1
  45. package/dist/scp/grouping.js +0 -0
  46. package/dist/scp/grouping.js.map +1 -1
  47. package/dist/scp/index.cjs +257 -670
  48. package/dist/scp/index.d.ts +6 -11
  49. package/dist/scp/index.d.ts.map +1 -1
  50. package/dist/scp/index.js +10 -28
  51. package/dist/scp/index.js.map +1 -1
  52. package/dist/scp/index.mjs +257 -658
  53. package/dist/scp/leaf-transport.d.ts +127 -39
  54. package/dist/scp/leaf-transport.d.ts.map +1 -1
  55. package/dist/scp/leaf-transport.js +30 -24
  56. package/dist/scp/leaf-transport.js.map +1 -1
  57. package/dist/scp/leaves.d.ts +57 -20
  58. package/dist/scp/leaves.d.ts.map +1 -1
  59. package/dist/scp/leaves.js +224 -65
  60. package/dist/scp/leaves.js.map +1 -1
  61. package/dist/scp/makesql/compile-select.d.ts +28 -1
  62. package/dist/scp/makesql/compile-select.d.ts.map +1 -1
  63. package/dist/scp/makesql/compile-select.js +19 -17
  64. package/dist/scp/makesql/compile-select.js.map +1 -1
  65. package/dist/scp/makesql/index.d.ts +2 -2
  66. package/dist/scp/makesql/index.d.ts.map +1 -1
  67. package/dist/scp/makesql/index.js +4 -6
  68. package/dist/scp/makesql/index.js.map +1 -1
  69. package/dist/scp/makesql/tx.d.ts +43 -89
  70. package/dist/scp/makesql/tx.d.ts.map +1 -1
  71. package/dist/scp/makesql/tx.js +45 -496
  72. package/dist/scp/makesql/tx.js.map +1 -1
  73. package/dist/scp/makesql/writeouttype.d.ts +5 -7
  74. package/dist/scp/makesql/writeouttype.d.ts.map +1 -1
  75. package/dist/scp/makesql/writeouttype.js +13 -19
  76. package/dist/scp/makesql/writeouttype.js.map +1 -1
  77. package/dist/scp/middleware.d.ts +4 -4
  78. package/dist/scp/middleware.d.ts.map +1 -1
  79. package/dist/scp/middleware.js +2 -2
  80. package/dist/scp/middleware.js.map +1 -1
  81. package/dist/scp/relation.d.ts +31 -12
  82. package/dist/scp/relation.d.ts.map +1 -1
  83. package/dist/scp/relation.js +16 -6
  84. package/dist/scp/relation.js.map +1 -1
  85. package/dist/scp/typed-object.d.ts +23 -19
  86. package/dist/scp/typed-object.d.ts.map +1 -1
  87. package/dist/scp/typed-object.js +24 -30
  88. package/dist/scp/typed-object.js.map +1 -1
  89. package/dist/scp/write-bundle.d.ts +21 -70
  90. package/dist/scp/write-bundle.d.ts.map +1 -1
  91. package/dist/scp/write-bundle.js +16 -80
  92. package/dist/scp/write-bundle.js.map +1 -1
  93. package/dist/types.d.ts +12 -0
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/types.js.map +1 -1
  96. package/docs/BENCHMARK.md +26 -22
  97. package/docs/COMPARISON.md +8 -4
  98. package/docs/api/README.md +1 -1
  99. package/docs/api/classes/Conditions.md +10 -10
  100. package/docs/api/classes/DBHandler.md +17 -17
  101. package/docs/api/classes/DBModel.md +111 -104
  102. package/docs/api/classes/LimitExceededError.md +8 -8
  103. package/docs/api/classes/Middleware.md +18 -18
  104. package/docs/api/classes/SqlRaw.md +6 -6
  105. package/docs/api/classes/SqlRef.md +7 -7
  106. package/docs/api/classes/Values.md +6 -6
  107. package/docs/api/classes/WriteInReadOnlyContextError.md +5 -5
  108. package/docs/api/classes/WriteOutsideTransactionError.md +5 -5
  109. package/docs/api/functions/belongsTo.md +2 -2
  110. package/docs/api/functions/closeAllPools.md +2 -2
  111. package/docs/api/functions/condsToRecord.md +2 -2
  112. package/docs/api/functions/createMiddleware.md +2 -2
  113. package/docs/api/functions/createPostgresDriver.md +2 -2
  114. package/docs/api/functions/createSqliteDriver.md +2 -2
  115. package/docs/api/functions/dbCast.md +3 -3
  116. package/docs/api/functions/dbCastIn.md +2 -2
  117. package/docs/api/functions/dbDynamic.md +3 -3
  118. package/docs/api/functions/dbFalse.md +2 -2
  119. package/docs/api/functions/dbImmediate.md +2 -2
  120. package/docs/api/functions/dbIn.md +2 -2
  121. package/docs/api/functions/dbNotNull.md +2 -2
  122. package/docs/api/functions/dbNow.md +2 -2
  123. package/docs/api/functions/dbNull.md +2 -2
  124. package/docs/api/functions/dbRaw.md +2 -2
  125. package/docs/api/functions/dbTrue.md +2 -2
  126. package/docs/api/functions/dbUuid.md +3 -3
  127. package/docs/api/functions/dbUuidIn.md +2 -2
  128. package/docs/api/functions/formatLocalDate.md +25 -0
  129. package/docs/api/functions/formatUTCDate.md +25 -0
  130. package/docs/api/functions/getDBConfig.md +2 -2
  131. package/docs/api/functions/getDBHandler.md +2 -2
  132. package/docs/api/functions/getTransactionConnection.md +2 -2
  133. package/docs/api/functions/getTransactionContext.md +2 -2
  134. package/docs/api/functions/hasMany.md +2 -2
  135. package/docs/api/functions/hasOne.md +2 -2
  136. package/docs/api/functions/initDBHandler.md +2 -2
  137. package/docs/api/functions/isAnySqlFragment.md +2 -2
  138. package/docs/api/functions/isConnectionError.md +26 -0
  139. package/docs/api/functions/isSqlCondition.md +2 -2
  140. package/docs/api/functions/isSqlFragment.md +2 -2
  141. package/docs/api/functions/isSqlRaw.md +2 -2
  142. package/docs/api/functions/isSqlRef.md +2 -2
  143. package/docs/api/functions/isSqlTypedFragment.md +2 -2
  144. package/docs/api/functions/model.md +6 -42
  145. package/docs/api/functions/parentRef.md +2 -2
  146. package/docs/api/functions/sql.md +7 -7
  147. package/docs/api/globals.md +57 -22
  148. package/docs/api/interfaces/Column.md +31 -31
  149. package/docs/api/interfaces/ColumnOptions.md +5 -4
  150. package/docs/api/interfaces/CreatedMiddlewareClass.md +7 -7
  151. package/docs/api/interfaces/DBConfig.md +13 -11
  152. package/docs/api/interfaces/DBConfigOptions.md +8 -8
  153. package/docs/api/interfaces/DeleteOptions.md +4 -4
  154. package/docs/api/interfaces/InsertOptions.md +8 -8
  155. package/docs/api/interfaces/LimitConfig.md +4 -4
  156. package/docs/api/interfaces/MiddlewareConfig.md +15 -15
  157. package/docs/api/interfaces/ModelOptions.md +8 -7
  158. package/docs/api/interfaces/PkeyResult.md +4 -4
  159. package/docs/api/interfaces/SelectOptions.md +17 -16
  160. package/docs/api/interfaces/SqlCondition.md +6 -6
  161. package/docs/api/interfaces/SqlFragment.md +5 -5
  162. package/docs/api/interfaces/SqlTypedFragment.md +7 -7
  163. package/docs/api/interfaces/TransactionOptions.md +7 -7
  164. package/docs/api/interfaces/UpdateManyOptions.md +4 -4
  165. package/docs/api/interfaces/UpdateOptions.md +4 -4
  166. package/docs/architecture.md +452 -0
  167. package/docs/benchmark-chart.svg +225 -249
  168. package/docs/design/phase-a-execution-context.md +2 -0
  169. package/package.json +20 -5
  170. package/dist/scp/writes.d.ts +0 -251
  171. package/dist/scp/writes.d.ts.map +0 -1
  172. package/dist/scp/writes.js +0 -176
  173. package/dist/scp/writes.js.map +0 -1
  174. package/docs/proposal/contracts-architecture-feasibility.md +0 -328
  175. package/docs/proposal/contracts-architecture.md +0 -579
  176. package/docs/proposal/litedbmodel-v2-scp-architecture.md +0 -433
  177. package/docs/proposal/sql-dynamic-expansion-spec.md +0 -175
  178. package/docs/proposal/v0-coverage-matrix.md +0 -157
  179. package/docs/proposal/v2-completeness-plan.md +0 -90
  180. package/docs/proposal/v2-sql-parity-checklist.md +0 -162
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -7,10 +7,10 @@
7
7
  # Function: dbUuid()
8
8
 
9
9
  ```ts
10
- function dbUuid(value: string, operator: string): DBCast;
10
+ function dbUuid(value: string, operator?: string): DBCast;
11
11
  ```
12
12
 
13
- Defined in: DBValues.ts:519
13
+ Defined in: [DBValues.ts:519](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBValues.ts#L519)
14
14
 
15
15
  Create a type-cast UUID value
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function dbUuidIn(values: string[]): DBCastArray;
11
11
  ```
12
12
 
13
- Defined in: DBValues.ts:544
13
+ Defined in: [DBValues.ts:544](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBValues.ts#L544)
14
14
 
15
15
  Create a type-cast UUID array for IN clause
16
16
 
@@ -0,0 +1,25 @@
1
+ [**litedbmodel v2.2.4**](../README.md)
2
+
3
+ ***
4
+
5
+ [litedbmodel](../globals.md) / formatLocalDate
6
+
7
+ # Function: formatLocalDate()
8
+
9
+ ```ts
10
+ function formatLocalDate(d: Date): string;
11
+ ```
12
+
13
+ Defined in: [TypeCast.ts:310](https://github.com/foo-ogawa/litedbmodel/blob/main/src/TypeCast.ts#L310)
14
+
15
+ Format Date as YYYY-MM-DD using local time components
16
+
17
+ ## Parameters
18
+
19
+ | Parameter | Type |
20
+ | ------ | ------ |
21
+ | `d` | `Date` |
22
+
23
+ ## Returns
24
+
25
+ `string`
@@ -0,0 +1,25 @@
1
+ [**litedbmodel v2.2.4**](../README.md)
2
+
3
+ ***
4
+
5
+ [litedbmodel](../globals.md) / formatUTCDate
6
+
7
+ # Function: formatUTCDate()
8
+
9
+ ```ts
10
+ function formatUTCDate(d: Date): string;
11
+ ```
12
+
13
+ Defined in: [TypeCast.ts:318](https://github.com/foo-ogawa/litedbmodel/blob/main/src/TypeCast.ts#L318)
14
+
15
+ Format Date as YYYY-MM-DD using UTC components
16
+
17
+ ## Parameters
18
+
19
+ | Parameter | Type |
20
+ | ------ | ------ |
21
+ | `d` | `Date` |
22
+
23
+ ## Returns
24
+
25
+ `string`
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function getDBConfig(): DBConfig | null;
11
11
  ```
12
12
 
13
- Defined in: DBHandler.ts:322
13
+ Defined in: [DBHandler.ts:327](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L327)
14
14
 
15
15
  Get global config
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function getDBHandler(): DBHandler;
11
11
  ```
12
12
 
13
- Defined in: DBHandler.ts:312
13
+ Defined in: [DBHandler.ts:317](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L317)
14
14
 
15
15
  Get global handler
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../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:48
13
+ Defined in: [DBModel.ts:74](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBModel.ts#L74)
14
14
 
15
15
  Get current transaction connection (if in a transaction)
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../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:41
13
+ Defined in: [DBModel.ts:67](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBModel.ts#L67)
14
14
 
15
15
  Get current transaction context (if in a transaction)
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function hasMany(keys: KeysFactory, options?: RelationDecoratorOptions): PropertyDecorator;
11
11
  ```
12
12
 
13
- Defined in: decorators.ts:798
13
+ Defined in: [decorators.ts:877](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L877)
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 v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function hasOne(keys: KeysFactory, options?: RelationDecoratorOptions): PropertyDecorator;
11
11
  ```
12
12
 
13
- Defined in: decorators.ts:862
13
+ Defined in: [decorators.ts:941](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L941)
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 v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function initDBHandler(config: DBConfig, options?: DBHandlerOptions): DBHandler;
11
11
  ```
12
12
 
13
- Defined in: DBHandler.ts:302
13
+ Defined in: [DBHandler.ts:307](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBHandler.ts#L307)
14
14
 
15
15
  Initialize global handler with config
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function isAnySqlFragment(value: unknown): value is SqlFragment | SqlTypedFragment<unknown, unknown> | SqlCondition<unknown>;
11
11
  ```
12
12
 
13
- Defined in: SqlFragment.ts:148
13
+ Defined in: [SqlFragment.ts:149](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L149)
14
14
 
15
15
  Matches any of SqlFragment, SqlTypedFragment, or SqlCondition.
16
16
 
@@ -0,0 +1,26 @@
1
+ [**litedbmodel v2.2.4**](../README.md)
2
+
3
+ ***
4
+
5
+ [litedbmodel](../globals.md) / isConnectionError
6
+
7
+ # Function: isConnectionError()
8
+
9
+ ```ts
10
+ function isConnectionError(error: Error): boolean;
11
+ ```
12
+
13
+ Defined in: [connection-errors.ts:5](https://github.com/foo-ogawa/litedbmodel/blob/main/src/connection-errors.ts#L5)
14
+
15
+ Check if an error indicates a broken/stale connection.
16
+ Used by both transaction retry (DBModel) and execute-level retry (drivers).
17
+
18
+ ## Parameters
19
+
20
+ | Parameter | Type |
21
+ | ------ | ------ |
22
+ | `error` | `Error` |
23
+
24
+ ## Returns
25
+
26
+ `boolean`
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function isSqlCondition(value: unknown): value is SqlCondition<unknown>;
11
11
  ```
12
12
 
13
- Defined in: SqlFragment.ts:136
13
+ Defined in: [SqlFragment.ts:137](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L137)
14
14
 
15
15
  ## Parameters
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function isSqlFragment(value: unknown): value is SqlFragment;
11
11
  ```
12
12
 
13
- Defined in: SqlFragment.ts:118
13
+ Defined in: [SqlFragment.ts:119](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L119)
14
14
 
15
15
  ## Parameters
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function isSqlRaw(value: unknown): value is SqlRaw;
11
11
  ```
12
12
 
13
- Defined in: SqlFragment.ts:154
13
+ Defined in: [SqlFragment.ts:155](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L155)
14
14
 
15
15
  ## Parameters
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function isSqlRef(value: unknown): value is SqlRef;
11
11
  ```
12
12
 
13
- Defined in: SqlFragment.ts:158
13
+ Defined in: [SqlFragment.ts:159](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L159)
14
14
 
15
15
  ## Parameters
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function isSqlTypedFragment(value: unknown): value is SqlTypedFragment<unknown, unknown>;
11
11
  ```
12
12
 
13
- Defined in: SqlFragment.ts:127
13
+ Defined in: [SqlFragment.ts:128](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L128)
14
14
 
15
15
  ## Parameters
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../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:927
15
+ Defined in: [decorators.ts:1006](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1006)
16
16
 
17
17
  Model class decorator.
18
18
 
@@ -85,7 +85,7 @@ const posts = await user.posts; // Batch loads with other users in context
85
85
  function model(tableName: string): <T>(constructor: T) => T;
86
86
  ```
87
87
 
88
- Defined in: decorators.ts:931
88
+ Defined in: [decorators.ts:1010](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1010)
89
89
 
90
90
  Model class decorator.
91
91
 
@@ -105,25 +105,7 @@ Automatically:
105
105
 
106
106
  ### Returns
107
107
 
108
- ```ts
109
- <T>(constructor: T): T;
110
- ```
111
-
112
- #### Type Parameters
113
-
114
- | Type Parameter |
115
- | ------ |
116
- | `T` *extends* (...`args`: `unknown`[]) => `object` |
117
-
118
- #### Parameters
119
-
120
- | Parameter | Type |
121
- | ------ | ------ |
122
- | `constructor` | `T` |
123
-
124
- #### Returns
125
-
126
- `T`
108
+ \<`T`\>(`constructor`: `T`) => `T`
127
109
 
128
110
  ### Column
129
111
 
@@ -170,7 +152,7 @@ const posts = await user.posts; // Batch loads with other users in context
170
152
  function model(tableName: string, options: ModelOptions): <T>(constructor: T) => T;
171
153
  ```
172
154
 
173
- Defined in: decorators.ts:935
155
+ Defined in: [decorators.ts:1014](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1014)
174
156
 
175
157
  Model class decorator.
176
158
 
@@ -191,25 +173,7 @@ Automatically:
191
173
 
192
174
  ### Returns
193
175
 
194
- ```ts
195
- <T>(constructor: T): T;
196
- ```
197
-
198
- #### Type Parameters
199
-
200
- | Type Parameter |
201
- | ------ |
202
- | `T` *extends* (...`args`: `unknown`[]) => `object` |
203
-
204
- #### Parameters
205
-
206
- | Parameter | Type |
207
- | ------ | ------ |
208
- | `constructor` | `T` |
209
-
210
- #### Returns
211
-
212
- `T`
176
+ \<`T`\>(`constructor`: `T`) => `T`
213
177
 
214
178
  ### Column
215
179
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function parentRef(column: ColumnRef): DBParentRef;
11
11
  ```
12
12
 
13
- Defined in: DBValues.ts:643
13
+ Defined in: [DBValues.ts:643](https://github.com/foo-ogawa/litedbmodel/blob/main/src/DBValues.ts#L643)
14
14
 
15
15
  Create a parent table column reference for correlated subqueries.
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v1.0.1**](../README.md)
1
+ [**litedbmodel v2.2.4**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -12,7 +12,7 @@
12
12
  function sql<V, M>(strings: TemplateStringsArray, col: Column<V, M>): SqlTypedFragment<V, M>;
13
13
  ```
14
14
 
15
- Defined in: SqlFragment.ts:234
15
+ Defined in: [SqlFragment.ts:235](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L235)
16
16
 
17
17
  Single Column interpolation → SqlTypedFragment (for Pattern A tuples or IS NULL conditions).
18
18
 
@@ -43,7 +43,7 @@ function sql<V, M>(
43
43
  value: V): SqlCondition<M>;
44
44
  ```
45
45
 
46
- Defined in: SqlFragment.ts:242
46
+ Defined in: [SqlFragment.ts:243](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L243)
47
47
 
48
48
  Single Column + 1 value → SqlCondition (Pattern B: `sql\`${Col} > ${value}\``).
49
49
 
@@ -76,7 +76,7 @@ function sql<V, M>(
76
76
  v2: V): SqlCondition<M>;
77
77
  ```
78
78
 
79
- Defined in: SqlFragment.ts:251
79
+ Defined in: [SqlFragment.ts:252](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L252)
80
80
 
81
81
  Single Column + 2 values → SqlCondition (Pattern B: BETWEEN).
82
82
 
@@ -109,7 +109,7 @@ function sql<V, M>(
109
109
  values: readonly V[]): SqlCondition<M>;
110
110
  ```
111
111
 
112
- Defined in: SqlFragment.ts:261
112
+ Defined in: [SqlFragment.ts:262](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L262)
113
113
 
114
114
  Single Column + array → SqlCondition (Pattern B: IN).
115
115
 
@@ -145,7 +145,7 @@ function sql(strings: TemplateStringsArray, ...values: (
145
145
  })[]): SqlFragment;
146
146
  ```
147
147
 
148
- Defined in: SqlFragment.ts:270
148
+ Defined in: [SqlFragment.ts:271](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L271)
149
149
 
150
150
  Multiple Columns / TABLE_NAME only → SqlFragment (for QUERY).
151
151
 
@@ -166,7 +166,7 @@ Multiple Columns / TABLE_NAME only → SqlFragment (for QUERY).
166
166
  function sql(strings: TemplateStringsArray, ...values: SqlInterpolation[]): SqlFragment;
167
167
  ```
168
168
 
169
- Defined in: SqlFragment.ts:278
169
+ Defined in: [SqlFragment.ts:279](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L279)
170
170
 
171
171
  General: mixed interpolation → SqlFragment (for withQuery / execute).
172
172
 
@@ -1,8 +1,8 @@
1
- [**litedbmodel v1.0.1**](README.md)
1
+ [**litedbmodel v2.2.4**](README.md)
2
2
 
3
3
  ***
4
4
 
5
- # litedbmodel v1.0.1
5
+ # litedbmodel v2.2.4
6
6
 
7
7
  litedbmodel - A lightweight TypeScript data access layer
8
8
 
@@ -69,19 +69,48 @@ Supports PostgreSQL and SQLite databases.
69
69
  type SkipType = typeof SKIP;
70
70
  ```
71
71
 
72
- Defined in: Column.ts:780
72
+ Defined in: [Column.ts:780](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L780)
73
73
 
74
74
  ***
75
75
 
76
76
  ### MiddlewareClass
77
77
 
78
78
  ```ts
79
- type MiddlewareClass = typeof Middleware & () => Middleware;
79
+ type MiddlewareClass = {
80
+ getCurrentContext: object;
81
+ };
82
+ ```
83
+
84
+ Defined in: [Middleware.ts:310](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L310)
85
+
86
+ Type for middleware class (not instance) — what [DBModel.use](classes/DBModel.md#use) registers.
87
+
88
+ The requirement is exactly what the registry's ONE consumer uses: a registered class is only ever
89
+ constructed and asked for the current request's instance (`MWClass.getCurrentContext()`), whose hook
90
+ is then looked up BY NAME and invoked (`DBModel._applyMiddleware` — the lookup is already a cast,
91
+ because which hooks a middleware implements is its own choice).
92
+
93
+ Naming `typeof Middleware` here instead demanded the whole static side — `_storage` / `getStorage`
94
+ included — and a `getCurrentContext()` returning a full `Middleware`. The class produced by
95
+ [createMiddleware](functions/createMiddleware.md) advertises neither: its state is its own shape, and a state key may
96
+ deliberately SHADOW a hook of the same name (`state: { count: 0 }` vs. the `count` hook — at runtime
97
+ the assigned own property wins over the prototype method). So the DOCUMENTED pairing
98
+ (`DBModel.use(DBModel.createMiddleware(…))`, README) did not typecheck even though it is the
99
+ runtime-correct call, and every stateful middleware in the README was affected.
100
+
101
+ #### Methods
102
+
103
+ ##### getCurrentContext()
104
+
105
+ ```ts
106
+ getCurrentContext(): object;
80
107
  ```
81
108
 
82
- Defined in: Middleware.ts:295
109
+ Defined in: [Middleware.ts:310](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Middleware.ts#L310)
110
+
111
+ ###### Returns
83
112
 
84
- Type for middleware class (not instance)
113
+ `object`
85
114
 
86
115
  ***
87
116
 
@@ -109,10 +138,13 @@ type SqlInterpolation =
109
138
  | readonly Date[]
110
139
  | {
111
140
  TABLE_NAME: string;
141
+ }
142
+ | {
143
+ getTableName: string;
112
144
  };
113
145
  ```
114
146
 
115
- Defined in: SqlFragment.ts:93
147
+ Defined in: [SqlFragment.ts:93](https://github.com/foo-ogawa/litedbmodel/blob/main/src/SqlFragment.ts#L93)
116
148
 
117
149
  Union of all types allowed as interpolated values in `sql` tagged templates.
118
150
 
@@ -140,7 +172,7 @@ const column: (columnNameOrOptions?: string | ColumnOptions) => PropertyDecorato
140
172
  };
141
173
  ```
142
174
 
143
- Defined in: decorators.ts:427
175
+ Defined in: [decorators.ts:516](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L516)
144
176
 
145
177
  Column decorator for defining model properties.
146
178
 
@@ -173,19 +205,19 @@ still work and can be used when you want to be explicit about the conversion.
173
205
 
174
206
  | Name | Type | Description | Defined in |
175
207
  | ------ | ------ | ------ | ------ |
176
- | `boolean()` | (`columnName?`: `string`) => `PropertyDecorator` | 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:441 |
177
- | `number()` | (`columnName?`: `string`) => `PropertyDecorator` | Number type conversion (from string) Preserves null for nullable columns, undefined stays undefined **Example** `@column.number() amount?: number;` | decorators.ts:457 |
178
- | `bigint()` | (`columnName?`: `string`) => `PropertyDecorator` | BigInt type conversion Preserves null for nullable columns, undefined stays undefined **Example** `@column.bigint() large_id?: bigint;` | decorators.ts:470 |
179
- | `datetime()` | (`columnName?`: `string`) => `PropertyDecorator` | 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?: Date;` | decorators.ts:500 |
180
- | `date()` | (`columnName?`: `string`) => `PropertyDecorator` | 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;` | decorators.ts:527 |
181
- | `stringArray()` | (`columnName?`: `string`) => `PropertyDecorator` | String array type conversion (text[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.stringArray() tags?: string[];` | decorators.ts:578 |
182
- | `intArray()` | (`columnName?`: `string`) => `PropertyDecorator` | Integer array type conversion (integer[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.intArray() scores?: number[];` | decorators.ts:595 |
183
- | `numericArray()` | (`columnName?`: `string`) => `PropertyDecorator` | Numeric array type conversion (numeric[], allows null elements) Preserves null for nullable columns, undefined stays undefined **Example** `@column.numericArray() values?: (number | null)[];` | decorators.ts:612 |
184
- | `booleanArray()` | (`columnName?`: `string`) => `PropertyDecorator` | Boolean array type conversion (boolean[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.booleanArray() flags?: (boolean | null)[];` | decorators.ts:629 |
185
- | `datetimeArray()` | (`columnName?`: `string`) => `PropertyDecorator` | DateTime array type conversion (timestamp[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.datetimeArray() event_dates?: (Date | null)[];` | decorators.ts:646 |
186
- | `json()` | \<`T`\>(`columnName?`: `string`) => `PropertyDecorator` | 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:672 |
187
- | `uuid()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => `PropertyDecorator` | 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:707 |
188
- | `custom()` | \<`T`\>(`castFn`: (`value`: `unknown`) => `T`, `serializeFn?`: `SerializeFn`, `columnName?`: `string`) => `PropertyDecorator` | 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:729 |
208
+ | `boolean()` | (`columnName?`: `string`) => `PropertyDecorator` | 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:530](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L530) |
209
+ | `number()` | (`columnName?`: `string`) => `PropertyDecorator` | Number type conversion (from string) Preserves null for nullable columns, undefined stays undefined **Example** `@column.number() amount?: number;` | [decorators.ts:547](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L547) |
210
+ | `bigint()` | (`columnName?`: `string`) => `PropertyDecorator` | BigInt type conversion Preserves null for nullable columns, undefined stays undefined **Example** `@column.bigint() large_id?: bigint;` | [decorators.ts:560](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L560) |
211
+ | `datetime()` | (`columnName?`: `string`) => `PropertyDecorator` | 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?: Date;` | [decorators.ts:588](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L588) |
212
+ | `date()` | (`columnName?`: `string`) => `PropertyDecorator` | 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;` | [decorators.ts:618](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L618) |
213
+ | `stringArray()` | (`columnName?`: `string`) => `PropertyDecorator` | String array type conversion (text[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.stringArray() tags?: string[];` | [decorators.ts:657](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L657) |
214
+ | `intArray()` | (`columnName?`: `string`) => `PropertyDecorator` | Integer array type conversion (integer[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.intArray() scores?: number[];` | [decorators.ts:674](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L674) |
215
+ | `numericArray()` | (`columnName?`: `string`) => `PropertyDecorator` | Numeric array type conversion (numeric[], allows null elements) Preserves null for nullable columns, undefined stays undefined **Example** `@column.numericArray() values?: (number | null)[];` | [decorators.ts:691](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L691) |
216
+ | `booleanArray()` | (`columnName?`: `string`) => `PropertyDecorator` | Boolean array type conversion (boolean[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.booleanArray() flags?: (boolean | null)[];` | [decorators.ts:708](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L708) |
217
+ | `datetimeArray()` | (`columnName?`: `string`) => `PropertyDecorator` | DateTime array type conversion (timestamp[]) Preserves null for nullable columns, undefined stays undefined **Example** `@column.datetimeArray() event_dates?: (Date | null)[];` | [decorators.ts:725](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L725) |
218
+ | `json()` | \<`T`\>(`columnName?`: `string`) => `PropertyDecorator` | 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:751](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L751) |
219
+ | `uuid()` | (`columnNameOrOptions?`: `string` \| [`ColumnOptions`](interfaces/ColumnOptions.md)) => `PropertyDecorator` | 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:786](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L786) |
220
+ | `custom()` | \<`T`\>(`castFn`: (`value`: `unknown`) => `T`, `serializeFn?`: `SerializeFn`, `columnName?`: `string`) => `PropertyDecorator` | 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:808](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L808) |
189
221
 
190
222
  ### Other
191
223
 
@@ -195,7 +227,7 @@ still work and can be used when you want to be explicit about the conversion.
195
227
  const SKIP: typeof SKIP;
196
228
  ```
197
229
 
198
- Defined in: Column.ts:779
230
+ Defined in: [Column.ts:779](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L779)
199
231
 
200
232
  Sentinel value to skip a field in create/update operations.
201
233
  Use with conditional expressions to keep code as expressions instead of statements.
@@ -258,6 +290,9 @@ await User.update(conds, [
258
290
  - [isSqlRaw](functions/isSqlRaw.md)
259
291
  - [isSqlRef](functions/isSqlRef.md)
260
292
  - [sql](functions/sql.md)
293
+ - [formatLocalDate](functions/formatLocalDate.md)
294
+ - [formatUTCDate](functions/formatUTCDate.md)
295
+ - [isConnectionError](functions/isConnectionError.md)
261
296
  - [createPostgresDriver](functions/createPostgresDriver.md)
262
297
  - [createSqliteDriver](functions/createSqliteDriver.md)
263
298