litedbmodel 1.0.1 → 1.1.0
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 +17 -13
- package/dist/DBModel.d.ts +18 -18
- package/dist/DBModel.d.ts.map +1 -1
- package/dist/DBModel.js +9 -9
- package/dist/DBModel.js.map +1 -1
- package/dist/LazyRelation.js +7 -7
- package/dist/LazyRelation.js.map +1 -1
- package/dist/SqlFragment.js +1 -1
- package/dist/SqlFragment.js.map +1 -1
- package/dist/decorators.d.ts +6 -7
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +36 -15
- package/dist/decorators.js.map +1 -1
- package/dist/types.d.ts +0 -9
- package/dist/types.d.ts.map +1 -1
- package/docs/COMPARISON.md +4 -2
- package/docs/api/README.md +61 -9
- package/docs/api/classes/Conditions.md +75 -8
- package/docs/api/classes/DBHandler.md +3 -3
- package/docs/api/classes/DBModel.md +260 -106
- package/docs/api/classes/LimitExceededError.md +1 -1
- package/docs/api/classes/Middleware.md +1 -1
- package/docs/api/classes/SqlRaw.md +53 -0
- package/docs/api/classes/SqlRef.md +59 -0
- package/docs/api/classes/Values.md +6 -6
- package/docs/api/classes/WriteInReadOnlyContextError.md +1 -1
- package/docs/api/classes/WriteOutsideTransactionError.md +1 -1
- package/docs/api/functions/belongsTo.md +2 -2
- package/docs/api/functions/closeAllPools.md +1 -1
- package/docs/api/functions/condsToRecord.md +23 -0
- package/docs/api/functions/createMiddleware.md +68 -0
- package/docs/api/functions/createPostgresDriver.md +2 -2
- package/docs/api/functions/createSqliteDriver.md +1 -1
- package/docs/api/functions/dbCast.md +1 -1
- package/docs/api/functions/dbCastIn.md +1 -1
- package/docs/api/functions/dbDynamic.md +1 -1
- package/docs/api/functions/dbFalse.md +1 -1
- package/docs/api/functions/dbImmediate.md +1 -1
- package/docs/api/functions/dbIn.md +1 -1
- package/docs/api/functions/dbNotNull.md +1 -1
- package/docs/api/functions/dbNow.md +1 -1
- package/docs/api/functions/dbNull.md +1 -1
- package/docs/api/functions/dbRaw.md +1 -1
- package/docs/api/functions/dbTrue.md +1 -1
- package/docs/api/functions/dbUuid.md +1 -1
- package/docs/api/functions/dbUuidIn.md +1 -1
- package/docs/api/functions/getDBConfig.md +1 -1
- package/docs/api/functions/getDBHandler.md +1 -1
- package/docs/api/functions/getTransactionConnection.md +2 -2
- package/docs/api/functions/getTransactionContext.md +2 -2
- package/docs/api/functions/hasMany.md +2 -2
- package/docs/api/functions/hasOne.md +2 -2
- package/docs/api/functions/initDBHandler.md +1 -1
- package/docs/api/functions/isAnySqlFragment.md +25 -0
- package/docs/api/functions/isSqlCondition.md +23 -0
- package/docs/api/functions/isSqlFragment.md +23 -0
- package/docs/api/functions/isSqlRaw.md +23 -0
- package/docs/api/functions/isSqlRef.md +23 -0
- package/docs/api/functions/isSqlTypedFragment.md +23 -0
- package/docs/api/functions/model.md +4 -4
- package/docs/api/functions/parentRef.md +1 -1
- package/docs/api/functions/sql.md +182 -0
- package/docs/api/globals.md +71 -19
- package/docs/api/interfaces/Column.md +31 -31
- package/docs/api/interfaces/ColumnOptions.md +4 -4
- package/docs/api/interfaces/CreatedMiddlewareClass.md +110 -0
- package/docs/api/interfaces/DBConfig.md +2 -2
- package/docs/api/interfaces/DBConfigOptions.md +1 -1
- package/docs/api/interfaces/DeleteOptions.md +1 -1
- package/docs/api/interfaces/InsertOptions.md +2 -2
- package/docs/api/interfaces/LimitConfig.md +1 -1
- package/docs/api/interfaces/MiddlewareConfig.md +40 -0
- package/docs/api/interfaces/ModelOptions.md +1 -1
- package/docs/api/interfaces/PkeyResult.md +1 -1
- package/docs/api/interfaces/SelectOptions.md +1 -1
- package/docs/api/interfaces/SqlCondition.md +27 -0
- package/docs/api/interfaces/SqlFragment.md +20 -0
- package/docs/api/interfaces/SqlTypedFragment.md +29 -0
- package/docs/api/interfaces/TransactionOptions.md +1 -1
- package/docs/api/interfaces/UpdateManyOptions.md +1 -1
- package/docs/api/interfaces/UpdateOptions.md +1 -1
- package/docs/sql-tagged-template.md +5 -5
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v1.0.1**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: Conditions\<Model\>
|
|
8
8
|
|
|
9
|
-
Defined in: Column.ts:
|
|
9
|
+
Defined in: Column.ts:628
|
|
10
10
|
|
|
11
11
|
Type-safe builder for query conditions.
|
|
12
12
|
Use array literals for static conditions, builder for dynamic construction.
|
|
@@ -47,7 +47,7 @@ if (query.active) where.add(User.is_active, true);
|
|
|
47
47
|
new Conditions<Model>(initial?: Conds): Conditions<Model>;
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Defined in: Column.ts:
|
|
50
|
+
Defined in: Column.ts:634
|
|
51
51
|
|
|
52
52
|
Create a Conditions builder, optionally with initial conditions.
|
|
53
53
|
|
|
@@ -71,7 +71,7 @@ Create a Conditions builder, optionally with initial conditions.
|
|
|
71
71
|
get length(): number;
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Defined in: Column.ts:
|
|
74
|
+
Defined in: Column.ts:700
|
|
75
75
|
|
|
76
76
|
Get the number of conditions.
|
|
77
77
|
|
|
@@ -87,7 +87,7 @@ Get the number of conditions.
|
|
|
87
87
|
add<V>(column: Column<V, Model>, value: V | null | undefined): this;
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
Defined in: Column.ts:
|
|
90
|
+
Defined in: Column.ts:643
|
|
91
91
|
|
|
92
92
|
Add a type-safe column equality condition.
|
|
93
93
|
|
|
@@ -116,7 +116,7 @@ Add a type-safe column equality condition.
|
|
|
116
116
|
addRaw(condition: string, value?: unknown): this;
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Defined in: Column.ts:
|
|
119
|
+
Defined in: Column.ts:651
|
|
120
120
|
|
|
121
121
|
Add a raw condition with template literal (e.g., `${User.age} > ?`).
|
|
122
122
|
|
|
@@ -133,13 +133,80 @@ Add a raw condition with template literal (e.g., `${User.age} > ?`).
|
|
|
133
133
|
|
|
134
134
|
***
|
|
135
135
|
|
|
136
|
+
### addSql()
|
|
137
|
+
|
|
138
|
+
#### Call Signature
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
addSql<V>(fragment: SqlTypedFragment<V, Model>, value: V): this;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Defined in: Column.ts:670
|
|
145
|
+
|
|
146
|
+
Add a type-safe sql-tagged condition.
|
|
147
|
+
|
|
148
|
+
##### Type Parameters
|
|
149
|
+
|
|
150
|
+
| Type Parameter |
|
|
151
|
+
| ------ |
|
|
152
|
+
| `V` |
|
|
153
|
+
|
|
154
|
+
##### Parameters
|
|
155
|
+
|
|
156
|
+
| Parameter | Type |
|
|
157
|
+
| ------ | ------ |
|
|
158
|
+
| `fragment` | [`SqlTypedFragment`](../interfaces/SqlTypedFragment.md)\<`V`, `Model`\> |
|
|
159
|
+
| `value` | `V` |
|
|
160
|
+
|
|
161
|
+
##### Returns
|
|
162
|
+
|
|
163
|
+
`this`
|
|
164
|
+
|
|
165
|
+
##### Example
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
const where = new Conditions<User>();
|
|
169
|
+
where.addSql(sql`${User.age} > ?`, 18);
|
|
170
|
+
where.addSql(sql`${User.deleted_at} IS NULL`);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Call Signature
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
addSql(fragment: SqlTypedFragment<any, Model>): this;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Defined in: Column.ts:671
|
|
180
|
+
|
|
181
|
+
Add a type-safe sql-tagged condition.
|
|
182
|
+
|
|
183
|
+
##### Parameters
|
|
184
|
+
|
|
185
|
+
| Parameter | Type |
|
|
186
|
+
| ------ | ------ |
|
|
187
|
+
| `fragment` | [`SqlTypedFragment`](../interfaces/SqlTypedFragment.md)\<`any`, `Model`\> |
|
|
188
|
+
|
|
189
|
+
##### Returns
|
|
190
|
+
|
|
191
|
+
`this`
|
|
192
|
+
|
|
193
|
+
##### Example
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const where = new Conditions<User>();
|
|
197
|
+
where.addSql(sql`${User.age} > ?`, 18);
|
|
198
|
+
where.addSql(sql`${User.deleted_at} IS NULL`);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
***
|
|
202
|
+
|
|
136
203
|
### or()
|
|
137
204
|
|
|
138
205
|
```ts
|
|
139
206
|
or(...condGroups: readonly Conds[]): this;
|
|
140
207
|
```
|
|
141
208
|
|
|
142
|
-
Defined in: Column.ts:
|
|
209
|
+
Defined in: Column.ts:685
|
|
143
210
|
|
|
144
211
|
Add an OR condition group.
|
|
145
212
|
|
|
@@ -161,7 +228,7 @@ Add an OR condition group.
|
|
|
161
228
|
build(): Conds;
|
|
162
229
|
```
|
|
163
230
|
|
|
164
|
-
Defined in: Column.ts:
|
|
231
|
+
Defined in: Column.ts:693
|
|
165
232
|
|
|
166
233
|
Build the final array for use with find/count/delete.
|
|
167
234
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**litedbmodel
|
|
1
|
+
[**litedbmodel v1.0.1**](../README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -48,7 +48,7 @@ Defined in: DBHandler.ts:180
|
|
|
48
48
|
### getDriverType()
|
|
49
49
|
|
|
50
50
|
```ts
|
|
51
|
-
getDriverType(): "postgres" | "
|
|
51
|
+
getDriverType(): "postgres" | "mysql" | "sqlite";
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Defined in: DBHandler.ts:198
|
|
@@ -57,7 +57,7 @@ Get the driver type
|
|
|
57
57
|
|
|
58
58
|
#### Returns
|
|
59
59
|
|
|
60
|
-
`"postgres"` \| `"
|
|
60
|
+
`"postgres"` \| `"mysql"` \| `"sqlite"`
|
|
61
61
|
|
|
62
62
|
***
|
|
63
63
|
|