import { Column, Entity, JoinTable, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Author } from './author'; import { AuthorRole } from './author-role'; import { Work } from './work'; @Entity() export class WorkAuthor implements WorkAuthorEntityInterface { @PrimaryGeneratedColumn() public readonly id!: number; @ManyToOne(() => Work, (work: WorkEntityInterface) => work.workAuthors, { nullable: false, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) public work!: Promise; @ManyToMany(() => AuthorRole, (authorRole: AuthorRoleEntityInterface) => authorRole.workAuthors) @JoinTable() public authorRoles!: Promise; @ManyToOne(() => Author, (author: AuthorEntityInterface) => author.workAuthors, { nullable: false, onDelete: 'RESTRICT', onUpdate: 'CASCADE', }) public author!: Promise; @Column({ nullable: false, default: 0, }) public order!: number; }