1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.createHasManyRepositoryFactory = void 0;
|
8 | const tslib_1 = require("tslib");
|
9 | const debug_1 = tslib_1.__importDefault(require("debug"));
|
10 | const has_many_helpers_1 = require("./has-many.helpers");
|
11 | const has_many_inclusion_resolver_1 = require("./has-many.inclusion-resolver");
|
12 | const has_many_repository_1 = require("./has-many.repository");
|
13 | const debug = (0, debug_1.default)('loopback:repository:relations:has-many:repository-factory');
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function createHasManyRepositoryFactory(relationMetadata, targetRepositoryGetter) {
|
28 | const meta = (0, has_many_helpers_1.resolveHasManyMetadata)(relationMetadata);
|
29 | debug('Resolved HasMany relation metadata: %o', meta);
|
30 | const result = function (fkValue) {
|
31 |
|
32 | const constraint = { [meta.keyTo]: fkValue };
|
33 | return new has_many_repository_1.DefaultHasManyRepository(targetRepositoryGetter, constraint);
|
34 | };
|
35 | result.inclusionResolver = (0, has_many_inclusion_resolver_1.createHasManyInclusionResolver)(meta, targetRepositoryGetter);
|
36 | return result;
|
37 | }
|
38 | exports.createHasManyRepositoryFactory = createHasManyRepositoryFactory;
|
39 |
|
\ | No newline at end of file |