Implemented new Permission system on the DB side.

ref #22
This commit is contained in:
2020-12-17 20:46:54 +01:00
parent 39b932a81c
commit cc5a30980a
6 changed files with 64 additions and 56 deletions

View File

@@ -0,0 +1,24 @@
import { IsInt, IsOptional } from 'class-validator';
import { Entity, OneToMany, PrimaryGeneratedColumn, TableInheritance } from 'typeorm';
import { Permission } from './Permission';
/**
* Defines a admin user.
*/
@Entity()
@TableInheritance({ column: { name: "type", type: "varchar" } })
export abstract class Principal {
/**
* autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsInt()
id: number;
/**
* permissions
*/
@IsOptional()
@OneToMany(() => Permission, permission => permission.principal, { nullable: true })
permissions?: Permission[];
}