RenaiApp/src/main/entities/library/author-role.ts

35 lines
1022 B
TypeScript

import { Column, Entity, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { AuthorRoleName } from './author-role-name';
import { WorkAuthor } from './work-author';
/**
* This entity describes the role an author has in a work.
* Examples: story writing, drawing, animating, publishing, ...
*/
@Entity()
export class AuthorRole implements IdentifiableEntityInterface, MultiNamedEntityInterface, DescribableEntityInterface {
@PrimaryGeneratedColumn()
public id!: number;
@Column({
nullable: false,
default: '',
})
public nameCanonical!: string;
@OneToMany(() => AuthorRoleName, (authorRoleName: AuthorRoleName) => authorRoleName.entity)
public names!: Promise<AuthorRoleName[]>;
/**
* relation to the entity connecting with the author and work
*/
@ManyToMany(() => WorkAuthor, (workAuthor: WorkAuthor) => workAuthor.authorRoles)
public workAuthors!: Promise<WorkAuthor[]>;
@Column({
nullable: false,
default: '',
})
public description!: string;
}