Page Contents

Home > @loopback/repository > findByForeignKeys

findByForeignKeys() function

Finds model instances that contain any of the provided foreign key values.


export declare function findByForeignKeys<Target extends Entity, TargetRelations extends object, ForeignKey extends StringKeyOf<Target>>(targetRepository: EntityCrudRepository<Target, unknown, TargetRelations>, fkName: ForeignKey, fkValues: Target[ForeignKey][] | Target[ForeignKey], scope?: Filter<Target> & {
    totalLimit?: number;
}, options?: Options): Promise<(Target & TargetRelations)[]>;


Parameter Type Description
targetRepository EntityCrudRepository<Target, unknown, TargetRelations> The target repository where the related model instances are found
fkName ForeignKey Name of the foreign key
fkValues Target[ForeignKey][] | Target[ForeignKey] One value or array of values of the foreign key to be included
scope Filter<Target> & { totalLimit?: number; } (Optional) Additional scope constraints
options Options (Optional) Options for the operations


Promise<(Target & TargetRelations)[]>