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, unique: true }) role: string; @ManyToMany(() => user, (user) => user.roles, { nullable: false, onDelete: "CASCADE", onUpdate: "RESTRICT", }) users: user[]; @OneToMany(() => rolePermission, (rolePermission) => rolePermission.role, { cascade: ["insert"] }) permissions: rolePermission[]; }