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

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

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [belongsTo](./repository.belongsto.md)

## belongsTo() function

Decorator for belongsTo

<b>Signature:</b>

```typescript
export declare function belongsTo<T extends Entity>(targetResolver: EntityResolver<T>, definition?: Partial<BelongsToDefinition>, propertyDefinition?: Partial<PropertyDefinition>): (decoratedTarget: Entity, decoratedKey: string) => void;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetResolver | <code>EntityResolver&lt;T&gt;</code> | A resolver function that returns the target model for a belongsTo relation |
|  definition | <code>Partial&lt;BelongsToDefinition&gt;</code> | Optional metadata for setting up a belongsTo relation |
|  propertyDefinition | <code>Partial&lt;PropertyDefinition&gt;</code> | Optional metadata for setting up the property |

<b>Returns:</b>

`(decoratedTarget: Entity, decoratedKey: string) => void`

A property decorator


