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

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

[Home](./index.md) &gt; [@loopback/repository](./repository.md) &gt; [hasOne](./repository.hasone.md)

## hasOne() function

<b>Signature:</b>

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

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetResolver | <code>EntityResolver&lt;T&gt;</code> |  |
|  definition | <code>Partial&lt;HasOneDefinition&gt;</code> |  |

<b>Returns:</b>

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


