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

***

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

# Function: morphedByMany()

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

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

Declare a polymorphic many-to-many from the "inverse" side: the shared model
reaches back to each of the owning types through the same morph pivot table
(e.g. `Tag` —(taggables)→ `Post` / `Video`). The property is a
[ManyToMany](../interfaces/ManyToMany) collection with pivot methods.

## Parameters

### related

() => `unknown`

Lazy factory returning the related (owning) model class.

### options

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

Morph name, parent pivot key, and optional pivot config.

## Returns

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

## Example

```ts
class Tag extends BaseModel {
  \@morphedByMany(() => Post, { morphName: 'taggable', parentPivotKey: 'tag_id' })
  posts!: ManyToMany<Post>;
}
```
