44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryColumn } from "typeorm";
|
|
import { role } from "./role";
|
|
import { userPermission } from "./user_permission";
|
|
|
|
@Entity()
|
|
export class user {
|
|
@PrimaryColumn({ generated: "uuid", type: "varchar" })
|
|
id: string;
|
|
|
|
@Column({ type: "varchar", unique: true, length: 255 })
|
|
mail: string;
|
|
|
|
@Column({ type: "varchar", unique: true, length: 255 })
|
|
username: string;
|
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
firstname: string;
|
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
lastname: string;
|
|
|
|
@Column({ type: "varchar", length: 255 })
|
|
secret: string;
|
|
|
|
@Column({ type: "boolean", default: false })
|
|
static: boolean;
|
|
|
|
@Column({ type: "boolean", default: false })
|
|
isOwner: boolean;
|
|
|
|
@ManyToMany(() => role, (role) => role.users, {
|
|
nullable: false,
|
|
onDelete: "CASCADE",
|
|
onUpdate: "RESTRICT",
|
|
cascade: ["insert"],
|
|
})
|
|
@JoinTable({
|
|
name: "user_roles",
|
|
})
|
|
roles: role[];
|
|
|
|
@OneToMany(() => userPermission, (userPermission) => userPermission.user, { cascade: ["insert"] })
|
|
permissions: userPermission[];
|
|
}
|