LocChat/server/entities/role.entity.ts

23 lines
475 B
TypeScript
Raw Normal View History

2021-11-30 17:40:07 -05:00
import { Entity, PrimaryGeneratedColumn, OneToMany, Column } from 'typeorm';
import { UserRole } from './user_role.entity';
2021-12-01 22:18:26 -05:00
// Make sure to add aditional roles here then reseed
export enum RoleKey {
ADMIN = 'admin',
USER = 'user',
}
2021-11-30 17:40:07 -05:00
@Entity()
export class Role {
2021-12-01 22:18:26 -05:00
static ROLES = [RoleKey.ADMIN, RoleKey.USER];
2021-11-30 17:40:07 -05:00
@PrimaryGeneratedColumn()
id: number;
@Column()
2021-12-01 22:18:26 -05:00
key: RoleKey;
2021-11-30 17:40:07 -05:00
@OneToMany(() => UserRole, (userRole) => userRole.role)
userRoles: UserRole[];
}