Makes a "belongs to many" relation of the property
import { Model } from 'pinia-orm'import Role from './Role'import RoleUser from './RoleUser'class User extends Model { static entity = 'users' static fields () { return { id: this.attr(null), roles: this.belongsToMany(Role, RoleUser, 'user_id', 'role_id') } }}
import { Model, Attr, Str, BelongsToMany } from 'pinia-orm'import Role from './Role'import RoleUser from './RoleUser'class User extends Model { static entity = 'users' @Attr(null) id!: number | null @BelongsToMany(() => Role, () => RoleUser, 'user_id', 'role_id') roles!: Role[]}
function belongsToMany( related: typeof Model, pivot: typeof Model, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string,): BelongsToMany