role perms
This commit is contained in:
Executable
+22
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user