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

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

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

## ModelDefinition.hasOne() method

Define a new hasOne relation.

**Signature:**

```typescript
hasOne(name: string, definition: Omit<HasOneDefinition, 'name' | 'type' | 'targetsMany'>): this;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  name | string | The name of the hasOne relation. |
|  definition | Omit&lt;[HasOneDefinition](./repository.hasonedefinition.md)<!-- -->, 'name' \| 'type' \| 'targetsMany'&gt; | The definition of the hasOne relation. |

**Returns:**

this


