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

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

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [DefaultCrudRepository](./repository.defaultcrudrepository.md) &gt; [createBelongsToAccessorFor](./repository.defaultcrudrepository.createbelongstoaccessorfor.md)

## DefaultCrudRepository.createBelongsToAccessorFor() method

Function to create a belongs to accessor

<b>Signature:</b>

```typescript
protected createBelongsToAccessorFor<Target extends Entity, TargetId>(relationName: string, targetRepoGetter: Getter<EntityCrudRepository<Target, TargetId>>): BelongsToAccessor<Target, ID>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  relationName | <code>string</code> | Name of the relation defined on the source model |
|  targetRepoGetter | <code>Getter&lt;EntityCrudRepository&lt;Target, TargetId&gt;&gt;</code> |  |

<b>Returns:</b>

`BelongsToAccessor<Target, ID>`


