---
lang: en
title: 'API docs: repository.belongsto'
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.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 | [EntityResolver](./repository.entityresolver.md)<!-- -->&lt;T&gt; | A resolver function that returns the target model for a belongsTo relation |
|  definition | Partial&lt;[BelongsToDefinition](./repository.belongstodefinition.md)<!-- -->&gt; | Optional metadata for setting up a belongsTo relation |
|  propertyDefinition | Partial&lt;[PropertyDefinition](./repository.propertydefinition.md)<!-- -->&gt; | Optional metadata for setting up the property |

<b>Returns:</b>

(decoratedTarget: [Entity](./repository.entity.md)<!-- -->, decoratedKey: string) =&gt; void

A property decorator


