Documentation / @zerotal/orm / index / morphOne
Function: morphOne()
morphOne(
related,options): (_value,context) =>void
Defined in: packages/orm/src/model/decorators/morphOne.ts:30
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
The morph name and optional local key.
Returns
(_value, context) => void
Example
class User extends BaseModel {
\@morphOne(() => Image, { morphName: 'imageable' })
avatar!: MorphOne<Image>;
}