---
lang: en
title: 'API docs: repository.defaultcrudrepository._createhasonerepositoryfactoryfor'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.defaultcrudrepository._createhasonerepositoryfactoryfor.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; [\_createHasOneRepositoryFactoryFor](./repository.defaultcrudrepository._createhasonerepositoryfactoryfor.md)

## DefaultCrudRepository.\_createHasOneRepositoryFactoryFor() method

> Warning: This API is now obsolete.
> 
> Function to create a constrained hasOne relation repository factory
> 

<b>Signature:</b>

```typescript
protected _createHasOneRepositoryFactoryFor<Target extends Entity, TargetID, ForeignKeyType>(relationName: string, targetRepoGetter: Getter<EntityCrudRepository<Target, TargetID>>): HasOneRepositoryFactory<Target, ForeignKeyType>;
```

## 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>

`HasOneRepositoryFactory<Target, ForeignKeyType>`


