hasMany()

Makes a "has many" 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),      title: this.string(''),      comments: this.hasMany(Comment, 'postId')    }  }}

With Decorator

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

Typescript Declarations

function hasMany(  related: typeof Model,  foreignKey: string,  localKey?: string,): HasMany