Page Contents

Home > @loopback/repository > findByForeignKeys

findByForeignKeys() function

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

Signature:

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)[]>;

Parameters

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; } Additional scope constraints
options Options Options for the operations

Returns:

Promise<(Target & TargetRelations)[]>