35 lines
1012 B
TypeScript
35 lines
1012 B
TypeScript
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<WorkEntityInterface>;
|
|
|
|
@ManyToMany(() => AuthorRole, (authorRole: AuthorRoleEntityInterface) => authorRole.workAuthors)
|
|
@JoinTable()
|
|
public authorRoles!: Promise<AuthorRoleEntityInterface[]>;
|
|
|
|
@ManyToOne(() => Author, (author: AuthorEntityInterface) => author.workAuthors, {
|
|
nullable: false,
|
|
onDelete: 'RESTRICT',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public author!: Promise<AuthorEntityInterface>;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: 0,
|
|
})
|
|
public order!: number;
|
|
}
|