[**Documentation**](../../../README)

***

[Documentation](../../../README) / [zerotal](../../README) / [orm](../README) / morphOne

# Function: morphOne()

> **morphOne**(`related`, `options`): (`_value`, `context`) => `void`

Defined in: [packages/orm/src/model/decorators/morphOne.ts:30](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/orm/src/model/decorators/morphOne.ts#L30)

Declare the "one" side of a polymorphic one-to-one: the parent owns a single
related row that references it via `{morphName}_id` / `{morphName}_type`
columns (e.g. a `User` has one `Image` through an `imageable` morph).

## Parameters

### related

() => `unknown`

Lazy factory returning the related model class.

### options

[`MorphOneOptions`](../interfaces/MorphOneOptions)

The morph name and optional local key.

## Returns

(`_value`, `context`) => `void`

## Example

```ts
class User extends BaseModel {
  \@morphOne(() => Image, { morphName: 'imageable' })
  avatar!: MorphOne<Image>;
}
```
