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

***

[Documentation](../../../../README) / [@zerotal/orm](../../README) / [index](../README) / hasOneThrough

# Function: hasOneThrough()

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

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

Declare a has-one-through relation: reach a single related record across one
intermediate ("through") model (the one-to-one counterpart of
[hasManyThrough](hasManyThrough)).

## Parameters

### related

() => `unknown`

Lazy factory returning the far/related model class.

### through

() => `unknown`

Lazy factory returning the intermediate model class.

### options

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

First/second key configuration across the two hops.

## Returns

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

## Remarks

Not supported by has / whereHas; use eager
[with()](../classes/ModelQueryBuilder#with) to load it.

## Example

```ts
class Country extends BaseModel {
  \@hasOneThrough(() => Post, () => User, { firstKey: 'country_id', secondKey: 'user_id' })
  latestPost!: HasOne<Post>;
}
```
