ff-admin-server/src/entity/role.ts

22 lines
584 B
TypeScript

import { Column, Entity, ManyToMany, OneToMany, PrimaryColumn } from "typeorm";
import { user } from "./user";
import { rolePermission } from "./role_permission";
@Entity()
export class role {
@PrimaryColumn({ generated: "increment", type: "int" })
id: number;
@Column({ type: "varchar", length: 255 })
role: string;
@ManyToMany(() => user, (user) => user.roles, {
nullable: false,
onDelete: "CASCADE",
onUpdate: "RESTRICT",
})
users: user[];
@OneToMany(() => rolePermission, (rolePermission) => rolePermission.role)
permissions: rolePermission[];
}