1 | import { Entity } from '../../model';
|
2 | import { EntityCrudRepository } from '../../repositories';
|
3 | import { Getter, HasManyDefinition, InclusionResolver } from '../relation.types';
|
4 | import { HasManyRepository } from './has-many.repository';
|
5 | export interface HasManyRepositoryFactory<Target extends Entity, ForeignKeyType> {
|
6 | /**
|
7 | * Invoke the function to obtain HasManyRepository.
|
8 | */
|
9 | (fkValue: ForeignKeyType): HasManyRepository<Target>;
|
10 | /**
|
11 | * Use `resolver` property to obtain an InclusionResolver for this relation.
|
12 | */
|
13 | inclusionResolver: InclusionResolver<Entity, Target>;
|
14 | }
|
15 | /**
|
16 | * Enforces a constraint on a repository based on a relationship contract
|
17 | * between models. For example, if a Customer model is related to an Order model
|
18 | * via a HasMany relation, then, the relational repository returned by the
|
19 | * factory function would be constrained by a Customer model instance's id(s).
|
20 | *
|
21 | * @param relationMetadata - The relation metadata used to describe the
|
22 | * relationship and determine how to apply the constraint.
|
23 | * @param targetRepositoryGetter - The repository which represents the target model of a
|
24 | * relation attached to a datasource.
|
25 | * @returns The factory function which accepts a foreign key value to constrain
|
26 | * the given target repository
|
27 | */
|
28 | export declare function createHasManyRepositoryFactory<Target extends Entity, TargetID, ForeignKeyType>(relationMetadata: HasManyDefinition, targetRepositoryGetter: Getter<EntityCrudRepository<Target, TargetID>>): HasManyRepositoryFactory<Target, ForeignKeyType>;
|