@loopback/repository 4.1.2 → 5.0.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/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/invalid-polymorphism.error.d.ts +5 -0
- package/dist/errors/invalid-polymorphism.error.js +22 -0
- package/dist/errors/invalid-polymorphism.error.js.map +1 -0
- package/dist/model.d.ts +7 -1
- package/dist/model.js +14 -0
- package/dist/model.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.accessor.d.ts +6 -2
- package/dist/relations/belongs-to/belongs-to.accessor.js +18 -5
- package/dist/relations/belongs-to/belongs-to.accessor.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.helpers.d.ts +3 -0
- package/dist/relations/belongs-to/belongs-to.helpers.js +32 -8
- package/dist/relations/belongs-to/belongs-to.helpers.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.d.ts +5 -2
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.js +81 -8
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.repository.d.ts +28 -5
- package/dist/relations/belongs-to/belongs-to.repository.js +49 -10
- package/dist/relations/belongs-to/belongs-to.repository.js.map +1 -1
- package/dist/relations/has-many/has-many-through.helpers.d.ts +3 -0
- package/dist/relations/has-many/has-many-through.helpers.js +25 -1
- package/dist/relations/has-many/has-many-through.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many-through.inclusion-resolver.d.ts +3 -1
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js +92 -21
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository-factory.d.ts +3 -1
- package/dist/relations/has-many/has-many-through.repository-factory.js +7 -1
- package/dist/relations/has-many/has-many-through.repository-factory.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository.d.ts +66 -11
- package/dist/relations/has-many/has-many-through.repository.js +211 -35
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -1
- package/dist/relations/has-one/has-one.helpers.d.ts +3 -0
- package/dist/relations/has-one/has-one.helpers.js +34 -8
- package/dist/relations/has-one/has-one.helpers.js.map +1 -1
- package/dist/relations/has-one/has-one.inclusion-resolver.d.ts +6 -3
- package/dist/relations/has-one/has-one.inclusion-resolver.js +82 -7
- package/dist/relations/has-one/has-one.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-one/has-one.repository-factory.d.ts +9 -3
- package/dist/relations/has-one/has-one.repository-factory.js +13 -3
- package/dist/relations/has-one/has-one.repository-factory.js.map +1 -1
- package/dist/relations/has-one/has-one.repository.d.ts +58 -11
- package/dist/relations/has-one/has-one.repository.js +118 -15
- package/dist/relations/has-one/has-one.repository.js.map +1 -1
- package/dist/relations/index.d.ts +2 -0
- package/dist/relations/index.js +2 -0
- package/dist/relations/index.js.map +1 -1
- package/dist/relations/references-many/index.d.ts +4 -0
- package/dist/relations/references-many/index.js +12 -0
- package/dist/relations/references-many/index.js.map +1 -0
- package/dist/relations/references-many/references-many.accessor.d.ts +17 -0
- package/dist/relations/references-many/references-many.accessor.js +40 -0
- package/dist/relations/references-many/references-many.accessor.js.map +1 -0
- package/dist/relations/references-many/references-many.decorator.d.ts +11 -0
- package/dist/relations/references-many/references-many.decorator.js +73 -0
- package/dist/relations/references-many/references-many.decorator.js.map +1 -0
- package/dist/relations/references-many/references-many.helpers.d.ts +17 -0
- package/dist/relations/references-many/references-many.helpers.js +63 -0
- package/dist/relations/references-many/references-many.helpers.js.map +1 -0
- package/dist/relations/references-many/references-many.inclusion-resolver.d.ts +14 -0
- package/dist/relations/references-many/references-many.inclusion-resolver.js +42 -0
- package/dist/relations/references-many/references-many.inclusion-resolver.js.map +1 -0
- package/dist/relations/references-many/references-many.repository.d.ts +28 -0
- package/dist/relations/references-many/references-many.repository.js +33 -0
- package/dist/relations/references-many/references-many.repository.js.map +1 -0
- package/dist/relations/relation.decorator.d.ts +0 -6
- package/dist/relations/relation.decorator.js +1 -13
- package/dist/relations/relation.decorator.js.map +1 -1
- package/dist/relations/relation.filter.solver.d.ts +2 -0
- package/dist/relations/relation.filter.solver.js +57 -0
- package/dist/relations/relation.filter.solver.js.map +1 -0
- package/dist/relations/relation.helpers.js +16 -1
- package/dist/relations/relation.helpers.js.map +1 -1
- package/dist/relations/relation.types.d.ts +52 -1
- package/dist/relations/relation.types.js.map +1 -1
- package/dist/repositories/legacy-juggler-bridge.d.ts +35 -8
- package/dist/repositories/legacy-juggler-bridge.js +36 -14
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
- package/package.json +13 -13
- package/src/errors/index.ts +1 -0
- package/src/errors/invalid-polymorphism.error.ts +28 -0
- package/src/model.ts +19 -0
- package/src/relations/belongs-to/belongs-to.accessor.ts +35 -6
- package/src/relations/belongs-to/belongs-to.helpers.ts +36 -9
- package/src/relations/belongs-to/belongs-to.inclusion-resolver.ts +108 -17
- package/src/relations/belongs-to/belongs-to.repository.ts +77 -17
- package/src/relations/has-many/has-many-through.helpers.ts +27 -1
- package/src/relations/has-many/has-many-through.inclusion-resolver.ts +117 -26
- package/src/relations/has-many/has-many-through.repository-factory.ts +21 -3
- package/src/relations/has-many/has-many-through.repository.ts +343 -76
- package/src/relations/has-one/has-one.helpers.ts +40 -13
- package/src/relations/has-one/has-one.inclusion-resolver.ts +109 -15
- package/src/relations/has-one/has-one.repository-factory.ts +34 -6
- package/src/relations/has-one/has-one.repository.ts +188 -35
- package/src/relations/index.ts +2 -0
- package/src/relations/references-many/index.ts +9 -0
- package/src/relations/references-many/references-many.accessor.ts +76 -0
- package/src/relations/references-many/references-many.decorator.ts +100 -0
- package/src/relations/references-many/references-many.helpers.ts +82 -0
- package/src/relations/references-many/references-many.inclusion-resolver.ts +80 -0
- package/src/relations/references-many/references-many.repository.ts +55 -0
- package/src/relations/relation.decorator.ts +0 -12
- package/src/relations/relation.filter.solver.ts +56 -0
- package/src/relations/relation.helpers.ts +16 -1
- package/src/relations/relation.types.ts +51 -0
- package/src/repositories/legacy-juggler-bridge.ts +78 -14
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createReferencesManyInclusionResolver = void 0;
|
|
8
|
+
const relation_helpers_1 = require("../relation.helpers");
|
|
9
|
+
const references_many_helpers_1 = require("./references-many.helpers");
|
|
10
|
+
/**
|
|
11
|
+
* Creates InclusionResolver for ReferencesMany relation.
|
|
12
|
+
* Notice that this function only generates the inclusionResolver.
|
|
13
|
+
* It doesn't register it for the source repository.
|
|
14
|
+
*
|
|
15
|
+
* Notice: scope field for inclusion is not supported yet
|
|
16
|
+
*
|
|
17
|
+
* @param meta - resolved ReferencesManyMetadata
|
|
18
|
+
* @param getTargetRepo - target repository i.e where related instances are
|
|
19
|
+
*/
|
|
20
|
+
function createReferencesManyInclusionResolver(meta, getTargetRepo) {
|
|
21
|
+
const relationMeta = (0, references_many_helpers_1.resolveReferencesManyMetadata)(meta);
|
|
22
|
+
return async function fetchIncludedModels(entities, inclusion, options) {
|
|
23
|
+
if (!entities.length)
|
|
24
|
+
return [];
|
|
25
|
+
const sourceKey = relationMeta.keyFrom;
|
|
26
|
+
const sourceMap = entities.map(e => e[sourceKey]);
|
|
27
|
+
const sourceIds = sourceMap.flat();
|
|
28
|
+
const targetKey = relationMeta.keyTo;
|
|
29
|
+
const dedupedSourceIds = (0, relation_helpers_1.deduplicate)(sourceIds);
|
|
30
|
+
const scope = typeof inclusion === 'string' ? {} : inclusion.scope;
|
|
31
|
+
const targetRepo = await getTargetRepo();
|
|
32
|
+
const targetsFound = await (0, relation_helpers_1.findByForeignKeys)(targetRepo, targetKey, dedupedSourceIds.filter(e => e), scope, options);
|
|
33
|
+
return sourceMap.map(chainIds => {
|
|
34
|
+
if (!chainIds)
|
|
35
|
+
return [];
|
|
36
|
+
const targets = (0, relation_helpers_1.flattenTargetsOfOneToOneRelation)(chainIds, targetsFound, targetKey);
|
|
37
|
+
return targets.filter((v) => v != null);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.createReferencesManyInclusionResolver = createReferencesManyInclusionResolver;
|
|
42
|
+
//# sourceMappingURL=references-many.inclusion-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.inclusion-resolver.js","sourceRoot":"","sources":["../../../src/relations/references-many/references-many.inclusion-resolver.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAMhE,0DAK6B;AAM7B,uEAAwE;AAExE;;;;;;;;;GASG;AACH,SAAgB,qCAAqC,CAKnD,IAA8B,EAC9B,aAEC;IAED,MAAM,YAAY,GAAG,IAAA,uDAA6B,EAAC,IAAI,CAAC,CAAC;IAEzD,OAAO,KAAK,UAAU,mBAAmB,CACvC,QAAkB,EAClB,SAA0B,EAC1B,OAAiB;QAEjB,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAEhC,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;QACvC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAe,CAAC,SAAS,CAAC,CAAC,CAAC;QACjE,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,YAAY,CAAC,KAA4B,CAAC;QAC5D,MAAM,gBAAgB,GAAG,IAAA,8BAAW,EAAC,SAAS,CAAC,CAAC;QAEhD,MAAM,KAAK,GACT,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,SAAS,CAAC,KAAwB,CAAC;QAE3E,MAAM,UAAU,GAAG,MAAM,aAAa,EAAE,CAAC;QACzC,MAAM,YAAY,GAAG,MAAM,IAAA,oCAAiB,EAC1C,UAAU,EACV,SAAS,EACT,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC/B,KAAK,EACL,OAAO,CACR,CAAC;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC9B,IAAI,CAAC,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,IAAA,mDAAgC,EAC9C,QAAQ,EACR,YAAY,EACZ,SAAS,CACV,CAAC;YACF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAiC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA/CD,sFA+CC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Getter } from '@loopback/core';
|
|
2
|
+
import { DataObject, Options } from '../../common-types';
|
|
3
|
+
import { Entity } from '../../model';
|
|
4
|
+
import { EntityCrudRepository } from '../../repositories';
|
|
5
|
+
/**
|
|
6
|
+
* CRUD operations for a target repository of a ReferencesMany relation
|
|
7
|
+
*/
|
|
8
|
+
export interface ReferencesManyRepository<Target extends Entity> {
|
|
9
|
+
/**
|
|
10
|
+
* Gets the target model instance
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns A promise resolved with the target object or rejected
|
|
13
|
+
* with an EntityNotFoundError when target model instance was not found.
|
|
14
|
+
*/
|
|
15
|
+
get(options?: Options): Promise<Target>;
|
|
16
|
+
}
|
|
17
|
+
export declare class DefaultReferencesManyRepository<TargetEntity extends Entity, TargetIds, TargetRepository extends EntityCrudRepository<TargetEntity, TargetIds>> implements ReferencesManyRepository<TargetEntity> {
|
|
18
|
+
getTargetRepository: Getter<TargetRepository>;
|
|
19
|
+
constraint: DataObject<TargetEntity>;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor of DefaultReferencesManyEntityCrudRepository
|
|
22
|
+
* @param getTargetRepository - the getter of the related target model repository instance
|
|
23
|
+
* @param constraint - the key value pair representing foreign key name to constrain
|
|
24
|
+
* the target repository instance
|
|
25
|
+
*/
|
|
26
|
+
constructor(getTargetRepository: Getter<TargetRepository>, constraint: DataObject<TargetEntity>);
|
|
27
|
+
get(options?: Options): Promise<TargetEntity>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DefaultReferencesManyRepository = void 0;
|
|
8
|
+
const errors_1 = require("../../errors");
|
|
9
|
+
const repositories_1 = require("../../repositories");
|
|
10
|
+
class DefaultReferencesManyRepository {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor of DefaultReferencesManyEntityCrudRepository
|
|
13
|
+
* @param getTargetRepository - the getter of the related target model repository instance
|
|
14
|
+
* @param constraint - the key value pair representing foreign key name to constrain
|
|
15
|
+
* the target repository instance
|
|
16
|
+
*/
|
|
17
|
+
constructor(getTargetRepository, constraint) {
|
|
18
|
+
this.getTargetRepository = getTargetRepository;
|
|
19
|
+
this.constraint = constraint;
|
|
20
|
+
}
|
|
21
|
+
async get(options) {
|
|
22
|
+
const targetRepo = await this.getTargetRepository();
|
|
23
|
+
const result = await targetRepo.find((0, repositories_1.constrainFilter)(undefined, this.constraint), options);
|
|
24
|
+
if (!result.length) {
|
|
25
|
+
// We don't have a direct access to the foreign key value here :(
|
|
26
|
+
const id = 'constraint ' + JSON.stringify(this.constraint);
|
|
27
|
+
throw new errors_1.EntityNotFoundError(targetRepo.entityClass, id);
|
|
28
|
+
}
|
|
29
|
+
return result[0];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.DefaultReferencesManyRepository = DefaultReferencesManyRepository;
|
|
33
|
+
//# sourceMappingURL=references-many.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.repository.js","sourceRoot":"","sources":["../../../src/relations/references-many/references-many.repository.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAIhE,yCAAiD;AAEjD,qDAAyE;AAezE,MAAa,+BAA+B;IAM1C;;;;;OAKG;IACH,YACS,mBAA6C,EAC7C,UAAoC;QADpC,wBAAmB,GAAnB,mBAAmB,CAA0B;QAC7C,eAAU,GAAV,UAAU,CAA0B;IAC1C,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,OAAiB;QACzB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAClC,IAAA,8BAAe,EAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,EAC3C,OAAO,CACR,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,iEAAiE;YACjE,MAAM,EAAE,GAAG,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC3D,MAAM,IAAI,4BAAmB,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;SAC3D;QACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;CACF;AA9BD,0EA8BC"}
|
|
@@ -31,9 +31,3 @@ export declare function embedsMany(definition?: Object): PropertyDecorator;
|
|
|
31
31
|
* @returns A property decorator
|
|
32
32
|
*/
|
|
33
33
|
export declare function referencesOne(definition?: Object): PropertyDecorator;
|
|
34
|
-
/**
|
|
35
|
-
* Decorator for referencesMany
|
|
36
|
-
* @param definition
|
|
37
|
-
* @returns A property decorator
|
|
38
|
-
*/
|
|
39
|
-
export declare function referencesMany(definition?: Object): PropertyDecorator;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.referencesOne = exports.embedsMany = exports.embedsOne = exports.getModelRelations = exports.relation = exports.RELATIONS_KEY = void 0;
|
|
8
8
|
const core_1 = require("@loopback/core");
|
|
9
9
|
const decorators_1 = require("../decorators");
|
|
10
10
|
const relation_types_1 = require("./relation.types");
|
|
@@ -73,16 +73,4 @@ function referencesOne(definition) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
exports.referencesOne = referencesOne;
|
|
76
|
-
/**
|
|
77
|
-
* Decorator for referencesMany
|
|
78
|
-
* @param definition
|
|
79
|
-
* @returns A property decorator
|
|
80
|
-
*/
|
|
81
|
-
function referencesMany(definition) {
|
|
82
|
-
const rel = Object.assign({ type: relation_types_1.RelationType.referencesMany }, definition);
|
|
83
|
-
return core_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel, {
|
|
84
|
-
decoratorName: '@referencesMany',
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
exports.referencesMany = referencesMany;
|
|
88
76
|
//# sourceMappingURL=relation.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.decorator.js","sourceRoot":"","sources":["../../src/relations/relation.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAAwD;AACxD,8CAAmD;AAEnD,qDAA8C;AAEjC,QAAA,aAAa,GAAG,oBAAoB,CAAC;AA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C,EAAC,IAAI,EAAE,6BAAY,CAAC,UAAU,EAAC,EAAE,UAAU,CAAC,CAAC;IACvE,OAAO,+BAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,GAAG,EAAE;QAClE,aAAa,EAAE,aAAa;KAC7B,CAAC,CAAC;AACL,CAAC;AALD,gCAKC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,UAAmB;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,6BAAY,CAAC,aAAa,EAAC,EAAE,UAAU,CAAC,CAAC;IAC1E,OAAO,+BAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,GAAG,EAAE;QAClE,aAAa,EAAE,gBAAgB;KAChC,CAAC,CAAC;AACL,CAAC;AALD,sCAKC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.includeFieldIfNot = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
function includeFieldIfNot(fields, fieldToInclude) {
|
|
6
|
+
if (!fields) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
else if (Array.isArray(fields)) {
|
|
10
|
+
const fieldsCloned = fields.reduce((prev, current) => ({ ...prev, [current]: true }), {});
|
|
11
|
+
if (Object.keys(fieldsCloned).length > 0) {
|
|
12
|
+
if (fieldsCloned[fieldToInclude] === true) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
fieldsCloned[fieldToInclude] = true;
|
|
16
|
+
return fieldsCloned;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const fieldsCloned = (0, lodash_1.cloneDeep)(fields);
|
|
21
|
+
if (Object.keys(fieldsCloned).length > 0) {
|
|
22
|
+
let containsTrue = false;
|
|
23
|
+
for (const k in fieldsCloned) {
|
|
24
|
+
if (fieldsCloned[k] === true) {
|
|
25
|
+
containsTrue = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const k in fieldsCloned) {
|
|
29
|
+
if (k === fieldToInclude) {
|
|
30
|
+
if (fieldsCloned[k] === true) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (containsTrue) {
|
|
35
|
+
fieldsCloned[k] = true;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
delete fieldsCloned[k];
|
|
39
|
+
}
|
|
40
|
+
return fieldsCloned;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (containsTrue) {
|
|
45
|
+
fieldsCloned[fieldToInclude] = true;
|
|
46
|
+
return fieldsCloned;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.includeFieldIfNot = includeFieldIfNot;
|
|
57
|
+
//# sourceMappingURL=relation.filter.solver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.filter.solver.js","sourceRoot":"","sources":["../../src/relations/relation.filter.solver.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AAEjC,SAAgB,iBAAiB,CAC/B,MAA8B,EAC9B,cAAyC;IAEzC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAC;KACd;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAChC,MAAM,YAAY,GAAgC,MAAM,CAAC,MAAM,CAC7D,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAC,CAAC,EAC/C,EAAE,CACH,CAAC;QACF,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACxC,IAAI,YAAY,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE;gBACzC,OAAO,KAAK,CAAC;aACd;YACD,YAAY,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;YACpC,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,KAAK,CAAC;KACd;IAED,MAAM,YAAY,GAAG,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACxC,IAAI,YAAY,GAAG,KAAK,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;gBAC5B,YAAY,GAAG,IAAI,CAAC;aACrB;SACF;QACD,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,IAAI,CAAC,KAAK,cAAc,EAAE;gBACxB,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;oBAC5B,OAAO,KAAK,CAAC;iBACd;qBAAM;oBACL,IAAI,YAAY,EAAE;wBAChB,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;qBACxB;yBAAM;wBACL,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;qBACxB;oBACD,OAAO,YAAY,CAAC;iBACrB;aACF;SACF;QACD,IAAI,YAAY,EAAE;YAChB,YAAY,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;YACpC,OAAO,YAAY,CAAC;SACrB;aAAM;YACL,OAAO,KAAK,CAAC;SACd;KACF;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AApDD,8CAoDC"}
|
|
@@ -92,7 +92,22 @@ exports.findByForeignKeys = findByForeignKeys;
|
|
|
92
92
|
*/
|
|
93
93
|
async function includeRelatedModels(targetRepository, entities, include, options) {
|
|
94
94
|
entities = (0, lodash_1.cloneDeep)(entities);
|
|
95
|
-
|
|
95
|
+
if (options === null || options === void 0 ? void 0 : options.polymorphicType) {
|
|
96
|
+
include = include === null || include === void 0 ? void 0 : include.filter(inclusionFilter => {
|
|
97
|
+
if (typeof inclusionFilter === 'string') {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (inclusionFilter.targetType === undefined ||
|
|
102
|
+
inclusionFilter.targetType === (options === null || options === void 0 ? void 0 : options.polymorphicType)) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
include = (0, lodash_1.cloneDeep)(include);
|
|
110
|
+
}
|
|
96
111
|
const result = entities;
|
|
97
112
|
if (!include)
|
|
98
113
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.helpers.js","sourceRoot":"","sources":["../../src/relations/relation.helpers.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,4DAA4B;AAC5B,0DAAiC;AACjC,yDAAoC;AACpC,0BASY;AACZ,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,sCAAsC,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACI,KAAK,UAAU,iBAAiB,CAKrC,gBAAwE,EACxE,MAAkB,EAClB,QAAmD,EACnD,KAA8C,EAC9C,OAAiB;IAEjB,IAAI,KAAK,CAAC;IACV,KAAK,GAAG,IAAA,kBAAS,EAAC,KAAK,CAAC,CAAC;IACzB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACrC,KAAK,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,GAAG,EAAE,QAAQ,EAAC,CAA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,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACtD,IAAI,eAAe,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;YACrD,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1B;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAdD,kCAcC;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEtD,wEAAwE;IACxE,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAE1D,SAAS,KAAK,CAAC,MAAe;QAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AATD,gCASC"}
|
|
@@ -60,6 +60,10 @@ export interface HasManyDefinition extends RelationDefinitionBase {
|
|
|
60
60
|
*/
|
|
61
61
|
keyTo?: string;
|
|
62
62
|
keyFrom?: string;
|
|
63
|
+
/**
|
|
64
|
+
* With current architecture design, polymorphic type cannot be supported without through
|
|
65
|
+
* Consider using Source-hasMany->Through->hasOne->Target(polymorphic) for one-to-many relations
|
|
66
|
+
*/
|
|
63
67
|
/**
|
|
64
68
|
* Description of the through model of the hasManyThrough relation.
|
|
65
69
|
*
|
|
@@ -91,6 +95,20 @@ export interface HasManyDefinition extends RelationDefinitionBase {
|
|
|
91
95
|
* The foreign key of the target model defined in the through model, e.g. CategoryProductLink#productId
|
|
92
96
|
*/
|
|
93
97
|
keyTo?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The polymorphism of the target model. The discriminator is a key of *through* model.
|
|
100
|
+
* If the target model is not polymorphic, then the value should be left undefined or false;
|
|
101
|
+
* If the key on through model indicating the concrete class of the through instance is default
|
|
102
|
+
* i.e. camelCase(classNameOf(targetModelInstance)) + "Id"
|
|
103
|
+
* then the discriminator field can be undefined
|
|
104
|
+
*
|
|
105
|
+
* With current architecture design, polymorphic type cannot be supported without through
|
|
106
|
+
* Consider using Source hasMany Through hasOne Target(polymorphic)
|
|
107
|
+
* or Source hasMany Through belongsTo Target(polymorphic) for one-to-many relations
|
|
108
|
+
*/
|
|
109
|
+
polymorphic?: boolean | {
|
|
110
|
+
discriminator: string;
|
|
111
|
+
};
|
|
94
112
|
};
|
|
95
113
|
}
|
|
96
114
|
export interface BelongsToDefinition extends RelationDefinitionBase {
|
|
@@ -98,6 +116,16 @@ export interface BelongsToDefinition extends RelationDefinitionBase {
|
|
|
98
116
|
targetsMany: false;
|
|
99
117
|
keyFrom?: string;
|
|
100
118
|
keyTo?: string;
|
|
119
|
+
/**
|
|
120
|
+
* The polymorphism of the target model. The discriminator is a key of source model.
|
|
121
|
+
* If the target model is not polymorphic, then the value should be left undefined or false;
|
|
122
|
+
* If the key on source model indicating the concrete class of the target instance is default
|
|
123
|
+
* i.e. camelCase(classNameOf(throughModelInstance)) + "Id"
|
|
124
|
+
* Then the discriminator field can be undefined
|
|
125
|
+
*/
|
|
126
|
+
polymorphic?: boolean | {
|
|
127
|
+
discriminator: string;
|
|
128
|
+
};
|
|
101
129
|
}
|
|
102
130
|
export interface HasOneDefinition extends RelationDefinitionBase {
|
|
103
131
|
type: RelationType.hasOne;
|
|
@@ -114,11 +142,34 @@ export interface HasOneDefinition extends RelationDefinitionBase {
|
|
|
114
142
|
*/
|
|
115
143
|
keyTo?: string;
|
|
116
144
|
keyFrom?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The polymorphism of the target model. The discriminator is a key of source model.
|
|
147
|
+
* If the target model is not polymorphic, then the value should be left undefined or false;
|
|
148
|
+
* If the key on source model indicating the concrete class of the target instance is default
|
|
149
|
+
* i.e. camelCase(classNameOf(throughModelInstance)) + "Id"
|
|
150
|
+
* Then the discriminator field can be undefined
|
|
151
|
+
*/
|
|
152
|
+
polymorphic?: boolean | {
|
|
153
|
+
discriminator: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export interface ReferencesManyDefinition extends RelationDefinitionBase {
|
|
157
|
+
type: RelationType.referencesMany;
|
|
158
|
+
targetsMany: true;
|
|
159
|
+
/**
|
|
160
|
+
* keyTo: The foreign key used by the target model for this relation.
|
|
161
|
+
* keyFrom: The source key used by the source model for this relation.
|
|
162
|
+
*
|
|
163
|
+
* TODO(bajtos) Add relation description.
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
keyTo?: string;
|
|
167
|
+
keyFrom?: string;
|
|
117
168
|
}
|
|
118
169
|
/**
|
|
119
170
|
* A union type describing all possible Relation metadata objects.
|
|
120
171
|
*/
|
|
121
|
-
export declare type RelationMetadata = HasManyDefinition | BelongsToDefinition | HasOneDefinition | RelationDefinitionBase;
|
|
172
|
+
export declare type RelationMetadata = HasManyDefinition | BelongsToDefinition | HasOneDefinition | ReferencesManyDefinition | RelationDefinitionBase;
|
|
122
173
|
export { Getter } from '@loopback/core';
|
|
123
174
|
/**
|
|
124
175
|
* @returns An array of resolved values, the items must be ordered in the same
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.types.js","sourceRoot":"","sources":["../../src/relations/relation.types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAOhE,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EARW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAQvB;
|
|
1
|
+
{"version":3,"file":"relation.types.js","sourceRoot":"","sources":["../../src/relations/relation.types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAOhE,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EARW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAQvB;AA6LD,6EAA6E;AAC7E,uCAAsC;AAA9B,8FAAA,MAAM,OAAA"}
|
|
@@ -3,7 +3,7 @@ import { Filter, FilterExcludingWhere, InclusionFilter, Where } from '@loopback/
|
|
|
3
3
|
import legacy from 'loopback-datasource-juggler';
|
|
4
4
|
import { AnyObject, Command, Count, DataObject, NamedParameters, Options, PositionalParameters } from '../common-types';
|
|
5
5
|
import { Entity, Model } from '../model';
|
|
6
|
-
import { BelongsToAccessor, HasManyRepositoryFactory, HasManyThroughRepositoryFactory, HasOneRepositoryFactory, InclusionResolver } from '../relations';
|
|
6
|
+
import { BelongsToAccessor, HasManyRepositoryFactory, HasManyThroughRepositoryFactory, HasOneRepositoryFactory, InclusionResolver, ReferencesManyAccessor } from '../relations';
|
|
7
7
|
import { IsolationLevel, Transaction } from '../transaction';
|
|
8
8
|
import { EntityCrudRepository, TransactionalEntityRepository } from './repository';
|
|
9
9
|
export declare namespace juggler {
|
|
@@ -66,7 +66,7 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
|
|
|
66
66
|
* @param relationName - Name of the relation defined on the source model
|
|
67
67
|
* @param targetRepo - Target repository instance
|
|
68
68
|
*/
|
|
69
|
-
protected _createHasManyRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string,
|
|
69
|
+
protected _createHasManyRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>>): HasManyRepositoryFactory<Target, ForeignKeyType>;
|
|
70
70
|
/**
|
|
71
71
|
* Function to create a constrained relation repository factory
|
|
72
72
|
*
|
|
@@ -95,7 +95,7 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
|
|
|
95
95
|
* @param relationName - Name of the relation defined on the source model
|
|
96
96
|
* @param targetRepo - Target repository instance
|
|
97
97
|
*/
|
|
98
|
-
protected createHasManyRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string,
|
|
98
|
+
protected createHasManyRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>>): HasManyRepositoryFactory<Target, ForeignKeyType>;
|
|
99
99
|
/**
|
|
100
100
|
* Function to create a constrained hasManyThrough relation repository factory
|
|
101
101
|
*
|
|
@@ -126,7 +126,9 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
|
|
|
126
126
|
* @param targetRepo - Target repository instance
|
|
127
127
|
* @param throughRepo - Through repository instance
|
|
128
128
|
*/
|
|
129
|
-
protected createHasManyThroughRepositoryFactoryFor<Target extends Entity, TargetID, Through extends Entity, ThroughID, ForeignKeyType>(relationName: string,
|
|
129
|
+
protected createHasManyThroughRepositoryFactoryFor<Target extends Entity, TargetID, Through extends Entity, ThroughID, ForeignKeyType>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>> | {
|
|
130
|
+
[repoType: string]: Getter<EntityCrudRepository<Target, TargetID>>;
|
|
131
|
+
}, throughRepositoryGetter: Getter<EntityCrudRepository<Through, ThroughID>>): HasManyThroughRepositoryFactory<Target, TargetID, Through, ForeignKeyType>;
|
|
130
132
|
/**
|
|
131
133
|
* @deprecated
|
|
132
134
|
* Function to create a belongs to accessor
|
|
@@ -136,14 +138,18 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
|
|
|
136
138
|
* @param relationName - Name of the relation defined on the source model
|
|
137
139
|
* @param targetRepo - Target repository instance
|
|
138
140
|
*/
|
|
139
|
-
protected _createBelongsToAccessorFor<Target extends Entity, TargetId>(relationName: string,
|
|
141
|
+
protected _createBelongsToAccessorFor<Target extends Entity, TargetId>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetId>> | {
|
|
142
|
+
[repoType: string]: Getter<EntityCrudRepository<Target, TargetId>>;
|
|
143
|
+
}): BelongsToAccessor<Target, ID>;
|
|
140
144
|
/**
|
|
141
145
|
* Function to create a belongs to accessor
|
|
142
146
|
*
|
|
143
147
|
* @param relationName - Name of the relation defined on the source model
|
|
144
148
|
* @param targetRepo - Target repository instance
|
|
145
149
|
*/
|
|
146
|
-
protected createBelongsToAccessorFor<Target extends Entity, TargetId>(relationName: string,
|
|
150
|
+
protected createBelongsToAccessorFor<Target extends Entity, TargetId>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetId>> | {
|
|
151
|
+
[repoType: string]: Getter<EntityCrudRepository<Target, TargetId>>;
|
|
152
|
+
}): BelongsToAccessor<Target, ID>;
|
|
147
153
|
/**
|
|
148
154
|
* @deprecated
|
|
149
155
|
* Function to create a constrained hasOne relation repository factory
|
|
@@ -151,14 +157,35 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
|
|
|
151
157
|
* @param relationName - Name of the relation defined on the source model
|
|
152
158
|
* @param targetRepo - Target repository instance
|
|
153
159
|
*/
|
|
154
|
-
protected _createHasOneRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string,
|
|
160
|
+
protected _createHasOneRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>> | {
|
|
161
|
+
[repoType: string]: Getter<EntityCrudRepository<Target, TargetID>>;
|
|
162
|
+
}): HasOneRepositoryFactory<Target, ForeignKeyType>;
|
|
155
163
|
/**
|
|
156
164
|
* Function to create a constrained hasOne relation repository factory
|
|
157
165
|
*
|
|
158
166
|
* @param relationName - Name of the relation defined on the source model
|
|
159
167
|
* @param targetRepo - Target repository instance
|
|
160
168
|
*/
|
|
161
|
-
protected createHasOneRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string,
|
|
169
|
+
protected createHasOneRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>> | {
|
|
170
|
+
[repoType: string]: Getter<EntityCrudRepository<Target, TargetID>>;
|
|
171
|
+
}): HasOneRepositoryFactory<Target, ForeignKeyType>;
|
|
172
|
+
/**
|
|
173
|
+
* @deprecated
|
|
174
|
+
* Function to create a references many accessor
|
|
175
|
+
*
|
|
176
|
+
* Use `this.createReferencesManyAccessorFor()` instead
|
|
177
|
+
*
|
|
178
|
+
* @param relationName - Name of the relation defined on the source model
|
|
179
|
+
* @param targetRepo - Target repository instance
|
|
180
|
+
*/
|
|
181
|
+
protected _createReferencesManyAccessorFor<Target extends Entity, TargetId>(relationName: string, targetRepoGetter: Getter<EntityCrudRepository<Target, TargetId>>): ReferencesManyAccessor<Target, ID>;
|
|
182
|
+
/**
|
|
183
|
+
* Function to create a references many accessor
|
|
184
|
+
*
|
|
185
|
+
* @param relationName - Name of the relation defined on the source model
|
|
186
|
+
* @param targetRepo - Target repository instance
|
|
187
|
+
*/
|
|
188
|
+
protected createReferencesManyAccessorFor<Target extends Entity, TargetId>(relationName: string, targetRepoGetter: Getter<EntityCrudRepository<Target, TargetId>>): ReferencesManyAccessor<Target, ID>;
|
|
162
189
|
create(entity: DataObject<T>, options?: Options): Promise<T>;
|
|
163
190
|
createAll(entities: DataObject<T>[], options?: Options): Promise<T[]>;
|
|
164
191
|
save(entity: T, options?: Options): Promise<T>;
|
|
@@ -146,8 +146,8 @@ class DefaultCrudRepository {
|
|
|
146
146
|
* @param relationName - Name of the relation defined on the source model
|
|
147
147
|
* @param targetRepo - Target repository instance
|
|
148
148
|
*/
|
|
149
|
-
_createHasManyRepositoryFactoryFor(relationName,
|
|
150
|
-
return this.createHasManyRepositoryFactoryFor(relationName,
|
|
149
|
+
_createHasManyRepositoryFactoryFor(relationName, targetRepositoryGetter) {
|
|
150
|
+
return this.createHasManyRepositoryFactoryFor(relationName, targetRepositoryGetter);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* Function to create a constrained relation repository factory
|
|
@@ -177,9 +177,9 @@ class DefaultCrudRepository {
|
|
|
177
177
|
* @param relationName - Name of the relation defined on the source model
|
|
178
178
|
* @param targetRepo - Target repository instance
|
|
179
179
|
*/
|
|
180
|
-
createHasManyRepositoryFactoryFor(relationName,
|
|
180
|
+
createHasManyRepositoryFactoryFor(relationName, targetRepositoryGetter) {
|
|
181
181
|
const meta = this.entityClass.definition.relations[relationName];
|
|
182
|
-
return (0, relations_1.createHasManyRepositoryFactory)(meta,
|
|
182
|
+
return (0, relations_1.createHasManyRepositoryFactory)(meta, targetRepositoryGetter);
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Function to create a constrained hasManyThrough relation repository factory
|
|
@@ -211,9 +211,9 @@ class DefaultCrudRepository {
|
|
|
211
211
|
* @param targetRepo - Target repository instance
|
|
212
212
|
* @param throughRepo - Through repository instance
|
|
213
213
|
*/
|
|
214
|
-
createHasManyThroughRepositoryFactoryFor(relationName,
|
|
214
|
+
createHasManyThroughRepositoryFactoryFor(relationName, targetRepositoryGetter, throughRepositoryGetter) {
|
|
215
215
|
const meta = this.entityClass.definition.relations[relationName];
|
|
216
|
-
return (0, relations_1.createHasManyThroughRepositoryFactory)(meta,
|
|
216
|
+
return (0, relations_1.createHasManyThroughRepositoryFactory)(meta, targetRepositoryGetter, throughRepositoryGetter);
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* @deprecated
|
|
@@ -224,8 +224,8 @@ class DefaultCrudRepository {
|
|
|
224
224
|
* @param relationName - Name of the relation defined on the source model
|
|
225
225
|
* @param targetRepo - Target repository instance
|
|
226
226
|
*/
|
|
227
|
-
_createBelongsToAccessorFor(relationName,
|
|
228
|
-
return this.createBelongsToAccessorFor(relationName,
|
|
227
|
+
_createBelongsToAccessorFor(relationName, targetRepositoryGetter) {
|
|
228
|
+
return this.createBelongsToAccessorFor(relationName, targetRepositoryGetter);
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
231
|
* Function to create a belongs to accessor
|
|
@@ -233,9 +233,9 @@ class DefaultCrudRepository {
|
|
|
233
233
|
* @param relationName - Name of the relation defined on the source model
|
|
234
234
|
* @param targetRepo - Target repository instance
|
|
235
235
|
*/
|
|
236
|
-
createBelongsToAccessorFor(relationName,
|
|
236
|
+
createBelongsToAccessorFor(relationName, targetRepositoryGetter) {
|
|
237
237
|
const meta = this.entityClass.definition.relations[relationName];
|
|
238
|
-
return (0, relations_1.createBelongsToAccessor)(meta,
|
|
238
|
+
return (0, relations_1.createBelongsToAccessor)(meta, targetRepositoryGetter, this);
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
241
241
|
* @deprecated
|
|
@@ -244,8 +244,8 @@ class DefaultCrudRepository {
|
|
|
244
244
|
* @param relationName - Name of the relation defined on the source model
|
|
245
245
|
* @param targetRepo - Target repository instance
|
|
246
246
|
*/
|
|
247
|
-
_createHasOneRepositoryFactoryFor(relationName,
|
|
248
|
-
return this.createHasOneRepositoryFactoryFor(relationName,
|
|
247
|
+
_createHasOneRepositoryFactoryFor(relationName, targetRepositoryGetter) {
|
|
248
|
+
return this.createHasOneRepositoryFactoryFor(relationName, targetRepositoryGetter);
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
251
251
|
* Function to create a constrained hasOne relation repository factory
|
|
@@ -253,9 +253,31 @@ class DefaultCrudRepository {
|
|
|
253
253
|
* @param relationName - Name of the relation defined on the source model
|
|
254
254
|
* @param targetRepo - Target repository instance
|
|
255
255
|
*/
|
|
256
|
-
createHasOneRepositoryFactoryFor(relationName,
|
|
256
|
+
createHasOneRepositoryFactoryFor(relationName, targetRepositoryGetter) {
|
|
257
257
|
const meta = this.entityClass.definition.relations[relationName];
|
|
258
|
-
return (0, relations_1.createHasOneRepositoryFactory)(meta,
|
|
258
|
+
return (0, relations_1.createHasOneRepositoryFactory)(meta, targetRepositoryGetter);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* @deprecated
|
|
262
|
+
* Function to create a references many accessor
|
|
263
|
+
*
|
|
264
|
+
* Use `this.createReferencesManyAccessorFor()` instead
|
|
265
|
+
*
|
|
266
|
+
* @param relationName - Name of the relation defined on the source model
|
|
267
|
+
* @param targetRepo - Target repository instance
|
|
268
|
+
*/
|
|
269
|
+
_createReferencesManyAccessorFor(relationName, targetRepoGetter) {
|
|
270
|
+
return this.createReferencesManyAccessorFor(relationName, targetRepoGetter);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Function to create a references many accessor
|
|
274
|
+
*
|
|
275
|
+
* @param relationName - Name of the relation defined on the source model
|
|
276
|
+
* @param targetRepo - Target repository instance
|
|
277
|
+
*/
|
|
278
|
+
createReferencesManyAccessorFor(relationName, targetRepoGetter) {
|
|
279
|
+
const meta = this.entityClass.definition.relations[relationName];
|
|
280
|
+
return (0, relations_1.createReferencesManyAccessor)(meta, targetRepoGetter, this);
|
|
259
281
|
}
|
|
260
282
|
async create(entity, options) {
|
|
261
283
|
// perform persist hook
|