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 } from 'pinia-orm'import { Attr, BelongsToMany, Str } from 'pinia-orm/dist/decorators'import Role from './Role'import RoleUser from './RoleUser'class User extends Model { static entity = 'users' @Attr(null) declare id: number | null @BelongsToMany(() => Role, () => RoleUser, 'user_id', 'role_id') declare roles: Role[]}
function belongsToMany( related: typeof Model, pivot: typeof Model, foreignPivotKey: string, relatedPivotKey: string, parentKey?: string, relatedKey?: string,): BelongsToMany