---
lang: en
title: 'API docs: repository.findbyforeignkeys'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/repository
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> & {
    totalLimit?: number;
}, options?: Options): Promise<(Target & TargetRelations)[]>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetRepository | [EntityCrudRepository](./repository.entitycrudrepository.md)<!-- -->&lt;Target, unknown, TargetRelations&gt; | 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](./filter.filter.md)<!-- -->&lt;Target&gt; &amp; { totalLimit?: number; } | <i>(Optional)</i> Additional scope constraints |
|  options | [Options](./repository.options.md) | <i>(Optional)</i> Options for the operations |

<b>Returns:</b>

Promise&lt;(Target &amp; TargetRelations)\[\]&gt;


