---
lang: en
title: 'API docs: repository.findbyforeignkeys'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.repository.findbyforeignkeys.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [findByForeignKeys](./repository.findbyforeignkeys.md)

## findByForeignKeys() function

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

<b>Signature:</b>

```typescript
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>, options?: Options): Promise<(Target & TargetRelations)[]>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetRepository | <code>EntityCrudRepository&lt;Target, unknown, TargetRelations&gt;</code> | The target repository where the model instances are found |
|  fkName | <code>ForeignKey</code> | Name of the foreign key |
|  fkValues | <code>Target[ForeignKey][] &#124; Target[ForeignKey]</code> | One value or array of values of the foreign key to be included |
|  scope | <code>Filter&lt;Target&gt;</code> | Additional scope constraints (not currently supported) |
|  options | <code>Options</code> | Options for the operations |

<b>Returns:</b>

`Promise<(Target & TargetRelations)[]>`


