@travetto/model-sql 5.0.0 → 5.0.2
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/package.json +7 -7
- package/src/service.ts +6 -5
- package/support/test/query.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-sql",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "SQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sql",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"directory": "module/model-sql"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/config": "^5.0.
|
|
31
|
-
"@travetto/context": "^5.0.
|
|
32
|
-
"@travetto/model": "^5.0.
|
|
33
|
-
"@travetto/model-query": "^5.0.
|
|
30
|
+
"@travetto/config": "^5.0.2",
|
|
31
|
+
"@travetto/context": "^5.0.2",
|
|
32
|
+
"@travetto/model": "^5.0.2",
|
|
33
|
+
"@travetto/model-query": "^5.0.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/command": "^5.0.
|
|
37
|
-
"@travetto/test": "^5.0.
|
|
36
|
+
"@travetto/command": "^5.0.2",
|
|
37
|
+
"@travetto/test": "^5.0.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@travetto/command": {
|
package/src/service.ts
CHANGED
|
@@ -182,9 +182,9 @@ export class SQLModelService implements
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
@Transactional()
|
|
185
|
-
async updatePartial<T extends ModelType>(cls: Class<T>, item: Partial<T> & { id: string }): Promise<T> {
|
|
185
|
+
async updatePartial<T extends ModelType>(cls: Class<T>, item: Partial<T> & { id: string }, view?: string): Promise<T> {
|
|
186
186
|
const id = item.id;
|
|
187
|
-
const final = await ModelCrudUtil.naivePartialUpdate(cls,
|
|
187
|
+
const final = await ModelCrudUtil.naivePartialUpdate(cls, () => this.get(cls, id), item, view);
|
|
188
188
|
return this.update(cls, final);
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -273,7 +273,7 @@ export class SQLModelService implements
|
|
|
273
273
|
|
|
274
274
|
@Connected()
|
|
275
275
|
@Transactional()
|
|
276
|
-
async
|
|
276
|
+
async updateByQuery<T extends ModelType>(cls: Class<T>, item: T, query: ModelQuery<T>): Promise<T> {
|
|
277
277
|
await QueryVerifier.verify(cls, query);
|
|
278
278
|
const where = ModelQueryUtil.getWhereClause(cls, query.where);
|
|
279
279
|
where.id = item.id;
|
|
@@ -283,9 +283,10 @@ export class SQLModelService implements
|
|
|
283
283
|
|
|
284
284
|
@Connected()
|
|
285
285
|
@Transactional()
|
|
286
|
-
async
|
|
286
|
+
async updatePartialByQuery<T extends ModelType>(cls: Class<T>, query: ModelQuery<T>, data: Partial<T>): Promise<number> {
|
|
287
287
|
await QueryVerifier.verify(cls, query);
|
|
288
|
-
const
|
|
288
|
+
const item = await ModelCrudUtil.prePartialUpdate(cls, data);
|
|
289
|
+
const { count } = await this.#exec(this.#dialect.getUpdateSQL(SQLUtil.classToStack(cls), item, ModelQueryUtil.getWhereClause(cls, query.where)));
|
|
289
290
|
return count;
|
|
290
291
|
}
|
|
291
292
|
|
package/support/test/query.ts
CHANGED
|
@@ -2,11 +2,11 @@ import assert from 'node:assert';
|
|
|
2
2
|
|
|
3
3
|
import { Schema, FieldConfig } from '@travetto/schema';
|
|
4
4
|
import { Suite, Test } from '@travetto/test';
|
|
5
|
+
import { castTo } from '@travetto/runtime';
|
|
5
6
|
import { BaseModelSuite } from '@travetto/model/support/test/base';
|
|
6
7
|
|
|
7
8
|
import { VisitStack } from '../../src/internal/util';
|
|
8
9
|
import { SQLModelService } from '../../src/service';
|
|
9
|
-
import { castTo } from '@travetto/runtime';
|
|
10
10
|
|
|
11
11
|
@Schema()
|
|
12
12
|
class User {
|