Documentation / @zerotal/orm / index / morphToMany
Function: morphToMany()
morphToMany(
related,options): (_value,context) =>void
Defined in: packages/orm/src/model/decorators/morphToMany.ts:34
Declare a polymorphic many-to-many from the "owning" side: several parent types
share one pivot table that carries a _type discriminator, linking each to the
related model (e.g. Post / Video —(taggables)→ Tag). The property is a
ManyToMany collection with pivot methods.
Parameters
related
() => unknown
Lazy factory returning the related model class.
options
Morph name, related pivot key, and optional pivot config.
Returns
(_value, context) => void
Example
class Post extends BaseModel {
\@morphToMany(() => Tag, { morphName: 'taggable', relatedPivotKey: 'tag_id' })
tags!: ManyToMany<Tag>;
}