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

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

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [hasMany](./repository.hasmany.md)

## hasMany() function

Decorator for hasMany Calls property.array decorator underneath the hood and infers foreign key name from target model name unless explicitly specified

<b>Signature:</b>

```typescript
export declare function hasMany<T extends Entity>(targetResolver: EntityResolver<T>, definition?: Partial<HasManyDefinition>): (decoratedTarget: object, key: string) => void;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetResolver | <code>EntityResolver&lt;T&gt;</code> | Target model for hasMany relation |
|  definition | <code>Partial&lt;HasManyDefinition&gt;</code> | Optional metadata for setting up hasMany relation |

<b>Returns:</b>

`(decoratedTarget: object, key: string) => void`

A property decorator


