role perms

This commit is contained in:
2025-11-12 09:28:56 +03:30
parent 046286b559
commit 440c3721ce
31 changed files with 488 additions and 98 deletions
+22
View File
@@ -0,0 +1,22 @@
// 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 'src/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<Permission>(this);
@OneToMany(() => Admin, admin => admin.role)
admins = new Collection<Admin>(this);
@OneToOne(() => Restaurant, { owner: true, nullable: true })
restaurant?: Restaurant;
}