hasManyBy()

Makes a "has many by" relation of the property


Usage

import { Model } from 'pinia-orm'import Comment from './Comment'class Post extends Model {  static entity = 'posts'  static fields () {    return {      id: this.attr(null),      postIds: this.attr([]),      title: this.string(''),      comments: this.hasManyBy(Comment, 'postId')    }  }}

With Decorator

import { Model, Attr, Str, HasManyBy } from 'pinia-orm'import Comment from './Comment'class Post extends Model {  static entity = 'posts'    @Attr(null) id!: number | null  @Attr([]) postIds!: number[]  @Str('') title!: string  @HasManyBy(() => Comment, 'postIds') comments!: Comment[]}

Typescript Declarations

function hasManyBy(  related: typeof Model,  foreignKey: string,  ownerKey?: string,): HasManyBy