---
lang: en
title: 'API docs: repository.hasmanythroughrepository.link'
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.hasmanythroughrepository.link.html
---

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

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [HasManyThroughRepository](./repository.hasmanythroughrepository.md) &gt; [link](./repository.hasmanythroughrepository.link.md)

## HasManyThroughRepository.link() method

Creates a new many-to-many association to an existing target model instance

<b>Signature:</b>

```typescript
link(targetModelId: TargetID, options?: Options & {
        throughData?: DataObject<Through>;
        throughOptions?: Options;
    }): Promise<void>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetModelId | TargetID | The target model ID to link |
|  options | [Options](./repository.options.md) &amp; { throughData?: [DataObject](./repository.dataobject.md)<!-- -->&lt;Through&gt;; throughOptions?: [Options](./repository.options.md)<!-- -->; } |  |

<b>Returns:</b>

Promise&lt;void&gt;

A promise which resolves to the linked target model instance


