// role.entity.ts import { Collection, Entity, ManyToMany, OneToMany, OneToOne, Property } from '@mikro-orm/core'; import { BaseEntity } from '../../../common/entities/base.entity'; import { Admin } from './admin.entity'; import { Permission } from './permission.entity'; import { Restaurant } from '../../../modules/restaurants/entities/restaurant.entity'; import { RolePermission } from './rolePermission.entity'; @Entity() export class Role extends BaseEntity { @Property() name!: string; @ManyToMany({ entity: () => Permission, pivotEntity: () => RolePermission, inversedBy: p => p.roles }) permissions = new Collection(this); @OneToMany(() => Admin, admin => admin.role) admins = new Collection(this); @OneToOne(() => Restaurant, { owner: true, nullable: true }) restaurant?: Restaurant; }