@travetto/model-sql 4.1.3 → 4.1.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/package.json +3 -3
- package/src/internal/util.ts +3 -3
- package/src/service.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-sql",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
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,10 +27,10 @@
|
|
|
27
27
|
"directory": "module/model-sql"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/config": "^4.1.
|
|
30
|
+
"@travetto/config": "^4.1.2",
|
|
31
31
|
"@travetto/context": "^4.1.1",
|
|
32
32
|
"@travetto/model": "^4.1.3",
|
|
33
|
-
"@travetto/model-query": "^4.1.
|
|
33
|
+
"@travetto/model-query": "^4.1.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@travetto/command": "^4.1.1",
|
package/src/internal/util.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Class, TypedObject, ObjectUtil } from '@travetto/base';
|
|
2
2
|
import { SelectClause, SortClause } from '@travetto/model-query';
|
|
3
|
-
import { ModelRegistry, ModelType } from '@travetto/model';
|
|
3
|
+
import { ModelRegistry, ModelType, OptionalId } from '@travetto/model';
|
|
4
4
|
import { SchemaRegistry, ClassConfig, FieldConfig } from '@travetto/schema';
|
|
5
5
|
import { AllViewⲐ } from '@travetto/schema/src/internal/types';
|
|
6
6
|
|
|
@@ -173,7 +173,7 @@ export class SQLUtil {
|
|
|
173
173
|
/**
|
|
174
174
|
* Process a schema instance by visiting it synchronously. This is synchronous to prevent concurrent calls from breaking
|
|
175
175
|
*/
|
|
176
|
-
static visitSchemaInstance<T extends ModelType>(cls: Class<T>, instance: T
|
|
176
|
+
static visitSchemaInstance<T extends ModelType>(cls: Class<T>, instance: T | OptionalId<T>, handler: VisitHandler<unknown, VisitInstanceNode<unknown>>): void {
|
|
177
177
|
const pathObj: unknown[] = [instance];
|
|
178
178
|
this.visitSchemaSync(SchemaRegistry.get(cls), {
|
|
179
179
|
onRoot: (config) => {
|
|
@@ -334,7 +334,7 @@ export class SQLUtil {
|
|
|
334
334
|
/**
|
|
335
335
|
* Get insert statements for a given class, and its child tables
|
|
336
336
|
*/
|
|
337
|
-
static async getInserts<T extends ModelType>(cls: Class<T>, els: T[]): Promise<InsertWrapper[]> {
|
|
337
|
+
static async getInserts<T extends ModelType>(cls: Class<T>, els: (T | OptionalId<T>)[]): Promise<InsertWrapper[]> {
|
|
338
338
|
const ins: Record<string, InsertWrapper> = {};
|
|
339
339
|
|
|
340
340
|
const track = (stack: VisitStack[], value: unknown): void => {
|
package/src/service.ts
CHANGED
|
@@ -223,8 +223,9 @@ export class SQLModelService implements
|
|
|
223
223
|
new Map([...existingUpsertedIds.entries()].map(([k, v]) => [v, k]))
|
|
224
224
|
);
|
|
225
225
|
|
|
226
|
-
const get =
|
|
227
|
-
operations.map(x => x[k]).filter((x): x is T => !!x);
|
|
226
|
+
const get = <K extends keyof BulkOp<T>>(k: K): Required<BulkOp<T>>[K][] =>
|
|
227
|
+
operations.map(x => x[k]).filter((x): x is Required<BulkOp<T>>[K] => !!x);
|
|
228
|
+
|
|
228
229
|
const getStatements = async (k: keyof BulkOp<T>): Promise<InsertWrapper[]> =>
|
|
229
230
|
(await SQLUtil.getInserts(cls, get(k))).filter(x => !!x.records.length);
|
|
230
231
|
|