morphOne()

Makes a "morph one" relation of the property


Usage

import { Model } from 'pinia-orm'import Image from './Image'class User extends Model {  static entity = 'users'  static fields () {    return {      id: this.number(0),      name: this.string(''),      image: this.morphOne(Image, 'imageableId', 'imageableType')    }  }}

With Decorator

import { Model, Attr, Str, MorphOne } from 'pinia-orm'import Image from './Image'class User extends Model {  static entity = 'users'    @Attr(null) id!: number | null  @Str('') name!: string  @MorphOne(() => Image, 'imageableId', 'imageableType') image!: Image}

Typescript Declarations

function morphOne(  related: typeof Model,  id: string,  type: string,  localKey?: string,): MorphOne