Documentation / @zerotal/orm / index / morphMany
Function: morphMany()
morphMany(
related,options): (_value,context) =>void
Defined in: packages/orm/src/model/decorators/morphMany.ts:30
Declare the "one" side of a polymorphic one-to-many: the parent owns many
related rows that reference it via {morphName}_id / {morphName}_type
columns (e.g. a Post has many Comments through a commentable morph).
Parameters
related
() => unknown
Lazy factory returning the related model class.
options
The morph name and optional local key.
Returns
(_value, context) => void
Example
class Post extends BaseModel {
\@morphMany(() => Comment, { morphName: 'commentable' })
comments!: MorphMany<Comment>;
}