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

31 lines
933 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 IIdentifiableEntity, IMultiNamedEntity, IDescribableEntity {
@PrimaryGeneratedColumn()
public id: number;
@Column({
nullable: false,
})
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()
public description: string;
}