---
lang: en
title: 'API docs: repository.hasone'
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.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

**Signature:**

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

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  targetResolver | [EntityResolver](./repository.entityresolver.md)<!-- -->&lt;T&gt; |  |
|  definition | Partial&lt;[HasOneDefinition](./repository.hasonedefinition.md)<!-- -->&gt; | _(Optional)_ |

**Returns:**

(decoratedTarget: object, key: string) =&gt; void


