Page Contents
Home > @loopback/repository > DefaultBelongsToRepository > (constructor)
DefaultBelongsToRepository.(constructor)
Constructor of DefaultBelongsToEntityCrudRepository
Signature:
constructor(getTargetRepository: Getter<TargetRepository> | {
[repoType: string]: Getter<TargetRepository>;
}, constraint: DataObject<TargetEntity>, targetResolver: TypeResolver<Entity, typeof Entity>);
Parameters
Parameter | Type | Description |
---|---|---|
getTargetRepository | Getter<TargetRepository> | { [repoType: string]: Getter<TargetRepository>; } | either a dictionary of target model type - target repository instance or a single target repository instance e.g. if the target is of a non-polymorphic type “Student”, put the studentRepositoryGetterInstance if the target is of a polymorphic type “Person” which can be either a “Student” or a “Teacher” then put “{Student: studentRepositoryGetterInstance, Teacher: teacherRepositoryGetterInstance}” |
constraint | DataObject<TargetEntity> | the key value pair representing foreign key name to constrain the target repository instance |
targetResolver | TypeResolver<Entity, typeof Entity> | () => Target to resolve the target class e.g. if the target is of type “Student”, then put “() => Student” |