litedbmodel 2.2.6 → 2.2.7

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 (116) hide show
  1. package/README.md +145 -86
  2. package/dist/Column.d.ts +17 -4
  3. package/dist/Column.d.ts.map +1 -1
  4. package/dist/Column.js.map +1 -1
  5. package/dist/DBModel.d.ts +13 -14
  6. package/dist/DBModel.d.ts.map +1 -1
  7. package/dist/DBModel.js +20 -21
  8. package/dist/DBModel.js.map +1 -1
  9. package/dist/LazyRelation.d.ts +2 -2
  10. package/dist/LazyRelation.js +2 -2
  11. package/dist/decorators.d.ts +120 -60
  12. package/dist/decorators.d.ts.map +1 -1
  13. package/dist/decorators.js +379 -248
  14. package/dist/decorators.js.map +1 -1
  15. package/dist/index.cjs +283 -217
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/scp/coltype.d.ts +14 -5
  20. package/dist/scp/coltype.d.ts.map +1 -1
  21. package/dist/scp/coltype.js +35 -36
  22. package/dist/scp/coltype.js.map +1 -1
  23. package/dist/scp/decorator-adapter.d.ts +11 -15
  24. package/dist/scp/decorator-adapter.d.ts.map +1 -1
  25. package/dist/scp/decorator-adapter.js +11 -15
  26. package/dist/scp/decorator-adapter.js.map +1 -1
  27. package/dist/scp/index.cjs +186 -193
  28. package/dist/scp/index.mjs +186 -193
  29. package/dist/scp/makesql/json-array.d.ts +6 -0
  30. package/dist/scp/makesql/json-array.d.ts.map +1 -1
  31. package/dist/scp/makesql/json-array.js +17 -2
  32. package/dist/scp/makesql/json-array.js.map +1 -1
  33. package/dist/scp/makesql/tx.d.ts.map +1 -1
  34. package/dist/scp/makesql/tx.js +1 -3
  35. package/dist/scp/makesql/tx.js.map +1 -1
  36. package/dist/scp/relation.d.ts.map +1 -1
  37. package/dist/scp/relation.js +8 -10
  38. package/dist/scp/relation.js.map +1 -1
  39. package/docs/BENCHMARK.md +3 -3
  40. package/docs/COMPARISON.md +7 -7
  41. package/docs/api/README.md +18 -18
  42. package/docs/api/classes/Conditions.md +1 -1
  43. package/docs/api/classes/DBHandler.md +1 -1
  44. package/docs/api/classes/DBModel.md +82 -82
  45. package/docs/api/classes/LimitExceededError.md +1 -1
  46. package/docs/api/classes/Middleware.md +1 -1
  47. package/docs/api/classes/SqlRaw.md +1 -1
  48. package/docs/api/classes/SqlRef.md +1 -1
  49. package/docs/api/classes/Values.md +1 -1
  50. package/docs/api/classes/WriteInReadOnlyContextError.md +1 -1
  51. package/docs/api/classes/WriteOutsideTransactionError.md +1 -1
  52. package/docs/api/functions/belongsTo.md +10 -4
  53. package/docs/api/functions/closeAllPools.md +1 -1
  54. package/docs/api/functions/condsToRecord.md +2 -2
  55. package/docs/api/functions/createMiddleware.md +1 -1
  56. package/docs/api/functions/createPostgresDriver.md +1 -1
  57. package/docs/api/functions/createSqliteDriver.md +1 -1
  58. package/docs/api/functions/dbCast.md +1 -1
  59. package/docs/api/functions/dbCastIn.md +1 -1
  60. package/docs/api/functions/dbDynamic.md +1 -1
  61. package/docs/api/functions/dbFalse.md +1 -1
  62. package/docs/api/functions/dbImmediate.md +1 -1
  63. package/docs/api/functions/dbIn.md +1 -1
  64. package/docs/api/functions/dbNotNull.md +1 -1
  65. package/docs/api/functions/dbNow.md +1 -1
  66. package/docs/api/functions/dbNull.md +1 -1
  67. package/docs/api/functions/dbRaw.md +1 -1
  68. package/docs/api/functions/dbTrue.md +1 -1
  69. package/docs/api/functions/dbUuid.md +1 -1
  70. package/docs/api/functions/dbUuidIn.md +1 -1
  71. package/docs/api/functions/formatLocalDate.md +1 -1
  72. package/docs/api/functions/formatUTCDate.md +1 -1
  73. package/docs/api/functions/getDBConfig.md +1 -1
  74. package/docs/api/functions/getDBHandler.md +1 -1
  75. package/docs/api/functions/getTransactionConnection.md +1 -1
  76. package/docs/api/functions/getTransactionContext.md +1 -1
  77. package/docs/api/functions/hasMany.md +11 -5
  78. package/docs/api/functions/hasOne.md +10 -4
  79. package/docs/api/functions/initDBHandler.md +1 -1
  80. package/docs/api/functions/isAnySqlFragment.md +1 -1
  81. package/docs/api/functions/isConnectionError.md +1 -1
  82. package/docs/api/functions/isSqlCondition.md +1 -1
  83. package/docs/api/functions/isSqlFragment.md +1 -1
  84. package/docs/api/functions/isSqlRaw.md +1 -1
  85. package/docs/api/functions/isSqlRef.md +1 -1
  86. package/docs/api/functions/isSqlTypedFragment.md +1 -1
  87. package/docs/api/functions/model.md +8 -155
  88. package/docs/api/functions/parentRef.md +1 -1
  89. package/docs/api/functions/sql.md +1 -1
  90. package/docs/api/globals.md +96 -58
  91. package/docs/api/interfaces/Column.md +1 -1
  92. package/docs/api/interfaces/ColumnDecorator.md +81 -0
  93. package/docs/api/interfaces/ColumnOptions.md +6 -10
  94. package/docs/api/interfaces/CreatedMiddlewareClass.md +1 -1
  95. package/docs/api/interfaces/DBConfig.md +1 -1
  96. package/docs/api/interfaces/DBConfigOptions.md +1 -1
  97. package/docs/api/interfaces/DeleteOptions.md +1 -1
  98. package/docs/api/interfaces/InsertOptions.md +1 -1
  99. package/docs/api/interfaces/LimitConfig.md +1 -1
  100. package/docs/api/interfaces/MiddlewareConfig.md +1 -1
  101. package/docs/api/interfaces/ModelClassDecorator.md +64 -0
  102. package/docs/api/interfaces/ModelOptions.md +1 -1
  103. package/docs/api/interfaces/PkeyResult.md +1 -1
  104. package/docs/api/interfaces/RelationDecorator.md +72 -0
  105. package/docs/api/interfaces/SelectOptions.md +1 -1
  106. package/docs/api/interfaces/SqlCondition.md +1 -1
  107. package/docs/api/interfaces/SqlFragment.md +1 -1
  108. package/docs/api/interfaces/SqlTypedFragment.md +1 -1
  109. package/docs/api/interfaces/TransactionOptions.md +1 -1
  110. package/docs/api/interfaces/UpdateManyOptions.md +1 -1
  111. package/docs/api/interfaces/UpdateOptions.md +1 -1
  112. package/docs/api-guide.md +17 -17
  113. package/docs/architecture.md +3 -3
  114. package/docs/sql-tagged-template.md +5 -5
  115. package/eslint-plugin/rules/require-declare-for-relations.js +59 -4
  116. package/package.json +8 -7
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -7,14 +7,20 @@
7
7
  # Function: belongsTo()
8
8
 
9
9
  ```ts
10
- function belongsTo(keys: KeysFactory, options?: RelationDecoratorOptions): PropertyDecorator;
10
+ function belongsTo<Value>(keys: KeysFactory, options?: RelationDecoratorOptions): RelationDecorator<Value>;
11
11
  ```
12
12
 
13
- Defined in: [decorators.ts:909](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L909)
13
+ Defined in: [decorators.ts:1032](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1032)
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.
17
17
 
18
+ ## Type Parameters
19
+
20
+ | Type Parameter | Default type |
21
+ | ------ | ------ |
22
+ | `Value` | `unknown` |
23
+
18
24
  ## Parameters
19
25
 
20
26
  | Parameter | Type | Description |
@@ -24,7 +30,7 @@ Defines a many-to-one relationship where this model belongs to a parent record.
24
30
 
25
31
  ## Returns
26
32
 
27
- `PropertyDecorator`
33
+ [`RelationDecorator`](../interfaces/RelationDecorator.md)\<`Value`\>
28
34
 
29
35
  ## Example
30
36
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -10,7 +10,7 @@
10
10
  function condsToRecord(conditions: Conds): Record<string, unknown>;
11
11
  ```
12
12
 
13
- Defined in: [Column.ts:1006](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L1006)
13
+ Defined in: [Column.ts:1020](https://github.com/foo-ogawa/litedbmodel/blob/main/src/Column.ts#L1020)
14
14
 
15
15
  ## Parameters
16
16
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -7,14 +7,20 @@
7
7
  # Function: hasMany()
8
8
 
9
9
  ```ts
10
- function hasMany(keys: KeysFactory, options?: RelationDecoratorOptions): PropertyDecorator;
10
+ function hasMany<Value>(keys: KeysFactory, options?: RelationDecoratorOptions): RelationDecorator<Value>;
11
11
  ```
12
12
 
13
- Defined in: [decorators.ts:877](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L877)
13
+ Defined in: [decorators.ts:1002](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1002)
14
14
 
15
15
  HasMany relation decorator (1:N).
16
16
  Defines a one-to-many relationship where this model has many related records.
17
17
 
18
+ ## Type Parameters
19
+
20
+ | Type Parameter | Default type |
21
+ | ------ | ------ |
22
+ | `Value` | `unknown` |
23
+
18
24
  ## Parameters
19
25
 
20
26
  | Parameter | Type | Description |
@@ -24,12 +30,12 @@ Defines a one-to-many relationship where this model has many related records.
24
30
 
25
31
  ## Returns
26
32
 
27
- `PropertyDecorator`
33
+ [`RelationDecorator`](../interfaces/RelationDecorator.md)\<`Value`\>
28
34
 
29
35
  ## Example
30
36
 
31
37
  ```typescript
32
- // Single key relation
38
+ // Single key relation (legacy decorators: `declare`; standard decorators: `posts!: …`)
33
39
  @hasMany(() => [User.id, Post.author_id])
34
40
  declare posts: Promise<Post[]>;
35
41
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -7,14 +7,20 @@
7
7
  # Function: hasOne()
8
8
 
9
9
  ```ts
10
- function hasOne(keys: KeysFactory, options?: RelationDecoratorOptions): PropertyDecorator;
10
+ function hasOne<Value>(keys: KeysFactory, options?: RelationDecoratorOptions): RelationDecorator<Value>;
11
11
  ```
12
12
 
13
- Defined in: [decorators.ts:941](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L941)
13
+ Defined in: [decorators.ts:1062](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1062)
14
14
 
15
15
  HasOne relation decorator (1:1).
16
16
  Defines a one-to-one relationship where this model has one related record.
17
17
 
18
+ ## Type Parameters
19
+
20
+ | Type Parameter | Default type |
21
+ | ------ | ------ |
22
+ | `Value` | `unknown` |
23
+
18
24
  ## Parameters
19
25
 
20
26
  | Parameter | Type | Description |
@@ -24,7 +30,7 @@ Defines a one-to-one relationship where this model has one related record.
24
30
 
25
31
  ## Returns
26
32
 
27
- `PropertyDecorator`
33
+ [`RelationDecorator`](../interfaces/RelationDecorator.md)\<`Value`\>
28
34
 
29
35
  ## Example
30
36
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -12,17 +12,7 @@
12
12
  function model<T>(constructor: T): T;
13
13
  ```
14
14
 
15
- Defined in: [decorators.ts:1006](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1006)
16
-
17
- Model class decorator.
18
-
19
- Can be used with or without table name:
20
- - `@model` - uses class name as table name (via TABLE_NAME)
21
- - `@model('users')` - sets TABLE_NAME to 'users'
22
-
23
- Automatically:
24
- 1. Sets static TABLE_NAME property (if table name provided)
25
- 2. Creates static Column properties for each
15
+ Defined in: [decorators.ts:1131](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1131)
26
16
 
27
17
  ### Type Parameters
28
18
 
@@ -40,62 +30,13 @@ Automatically:
40
30
 
41
31
  `T`
42
32
 
43
- ### Column
44
-
45
- decorated property
46
- 3. Generates typeCastFromDB() method from
47
-
48
- ### Column
49
-
50
- type conversion settings
51
- 4. Creates relation getters from @hasMany, @belongsTo,
52
-
53
- ### Has One
54
-
55
- decorators
56
-
57
- ### Example
58
-
59
- ```typescript
60
- @model('users')
61
- class User extends DBModel {
62
- @column() id?: number;
63
- @column() name?: string;
64
- @column.boolean() is_active?: boolean;
65
- @column.datetime() created_at?: Date;
66
-
67
- @hasMany(() => [User.id, Post.author_id])
68
- declare posts: Promise<Post[]>;
69
- }
70
-
71
- // Usage - call column to get name as string for computed property key
72
- await User.findAll({ [User.id()]: 1 });
73
-
74
- // Or use condition builders with spread
75
- await User.findAll({ ...User.is_active.eq(true) });
76
-
77
- // Access relations
78
- const user = await User.findOne([[User.id, 1]]);
79
- const posts = await user.posts; // Batch loads with other users in context
80
- ```
81
-
82
33
  ## Call Signature
83
34
 
84
35
  ```ts
85
- function model(tableName: string): <T>(constructor: T) => T;
36
+ function model(tableName: string): ModelClassDecorator;
86
37
  ```
87
38
 
88
- Defined in: [decorators.ts:1010](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1010)
89
-
90
- Model class decorator.
91
-
92
- Can be used with or without table name:
93
- - `@model` - uses class name as table name (via TABLE_NAME)
94
- - `@model('users')` - sets TABLE_NAME to 'users'
95
-
96
- Automatically:
97
- 1. Sets static TABLE_NAME property (if table name provided)
98
- 2. Creates static Column properties for each
39
+ Defined in: [decorators.ts:1135](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1135)
99
40
 
100
41
  ### Parameters
101
42
 
@@ -105,64 +46,15 @@ Automatically:
105
46
 
106
47
  ### Returns
107
48
 
108
- \<`T`\>(`constructor`: `T`) => `T`
109
-
110
- ### Column
111
-
112
- decorated property
113
- 3. Generates typeCastFromDB() method from
114
-
115
- ### Column
116
-
117
- type conversion settings
118
- 4. Creates relation getters from @hasMany, @belongsTo,
119
-
120
- ### Has One
121
-
122
- decorators
123
-
124
- ### Example
125
-
126
- ```typescript
127
- @model('users')
128
- class User extends DBModel {
129
- @column() id?: number;
130
- @column() name?: string;
131
- @column.boolean() is_active?: boolean;
132
- @column.datetime() created_at?: Date;
133
-
134
- @hasMany(() => [User.id, Post.author_id])
135
- declare posts: Promise<Post[]>;
136
- }
137
-
138
- // Usage - call column to get name as string for computed property key
139
- await User.findAll({ [User.id()]: 1 });
140
-
141
- // Or use condition builders with spread
142
- await User.findAll({ ...User.is_active.eq(true) });
143
-
144
- // Access relations
145
- const user = await User.findOne([[User.id, 1]]);
146
- const posts = await user.posts; // Batch loads with other users in context
147
- ```
49
+ [`ModelClassDecorator`](../interfaces/ModelClassDecorator.md)
148
50
 
149
51
  ## Call Signature
150
52
 
151
53
  ```ts
152
- function model(tableName: string, options: ModelOptions): <T>(constructor: T) => T;
54
+ function model(tableName: string, options: ModelOptions): ModelClassDecorator;
153
55
  ```
154
56
 
155
- Defined in: [decorators.ts:1014](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1014)
156
-
157
- Model class decorator.
158
-
159
- Can be used with or without table name:
160
- - `@model` - uses class name as table name (via TABLE_NAME)
161
- - `@model('users')` - sets TABLE_NAME to 'users'
162
-
163
- Automatically:
164
- 1. Sets static TABLE_NAME property (if table name provided)
165
- 2. Creates static Column properties for each
57
+ Defined in: [decorators.ts:1137](https://github.com/foo-ogawa/litedbmodel/blob/main/src/decorators.ts#L1137)
166
58
 
167
59
  ### Parameters
168
60
 
@@ -173,43 +65,4 @@ Automatically:
173
65
 
174
66
  ### Returns
175
67
 
176
- \<`T`\>(`constructor`: `T`) => `T`
177
-
178
- ### Column
179
-
180
- decorated property
181
- 3. Generates typeCastFromDB() method from
182
-
183
- ### Column
184
-
185
- type conversion settings
186
- 4. Creates relation getters from @hasMany, @belongsTo,
187
-
188
- ### Has One
189
-
190
- decorators
191
-
192
- ### Example
193
-
194
- ```typescript
195
- @model('users')
196
- class User extends DBModel {
197
- @column() id?: number;
198
- @column() name?: string;
199
- @column.boolean() is_active?: boolean;
200
- @column.datetime() created_at?: Date;
201
-
202
- @hasMany(() => [User.id, Post.author_id])
203
- declare posts: Promise<Post[]>;
204
- }
205
-
206
- // Usage - call column to get name as string for computed property key
207
- await User.findAll({ [User.id()]: 1 });
208
-
209
- // Or use condition builders with spread
210
- await User.findAll({ ...User.is_active.eq(true) });
211
-
212
- // Access relations
213
- const user = await User.findOne([[User.id, 1]]);
214
- const posts = await user.posts; // Batch loads with other users in context
215
- ```
68
+ [`ModelClassDecorator`](../interfaces/ModelClassDecorator.md)
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4
 
@@ -1,4 +1,4 @@
1
- [**litedbmodel v2.2.6**](../README.md)
1
+ [**litedbmodel v2.2.7**](../README.md)
2
2
 
3
3
  ***
4
4