import { Column, Entity, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { PercentCheck } from '../decorators/percent-check'; import { CollectionPart } from './collection-part'; import { Copy } from './copy'; import { Language } from './language'; import { Transformation } from './transformation'; import { WorkAuthor } from './work-author'; import { WorkCharacter } from './work-character'; import { WorkName } from './work-name'; import { WorkTag } from './work-tag'; import { World } from './world'; /** * This is the main library entity. * * It describes a work of art organized by this software. */ @Entity() @PercentCheck('rating') export class Work implements IIdentifiableEntity, IMultiNamedEntity { @PrimaryGeneratedColumn() public id: number; @Column({ nullable: false, }) public nameCanonical: string; @OneToMany(() => WorkName, (workName: WorkName) => workName.entity) public names: Promise; /** * digital representations of this work */ @OneToMany(() => Copy, (copy: Copy) => copy.original) public copies: Promise; /** * other works this work is a transformation of */ @OneToMany(() => Transformation, (transformation: Transformation) => transformation.byWork) public transformationOf: Promise; /** * other works this work is transformed by */ @OneToMany(() => Transformation, (transformation: Transformation) => transformation.ofWork) public transformedBy: Promise; /** * the authors/publishers of this work */ @OneToMany(() => WorkAuthor, (workAuthor: WorkAuthor) => workAuthor.work) public workAuthors: Promise; /** * tags describing this work */ @OneToMany(() => WorkTag, (workTag: WorkTag) => workTag.work) public workTags: Promise; /** * characters in this work */ @OneToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.work) public workCharacters: Promise; /** * fictional worlds in which this work takes place */ @ManyToMany(() => World, (world: World) => world.works) public worlds: Promise; /** * if this work i canon in above fictional world */ @Column({ nullable: false, default: false, }) public isCanonical: boolean; /** * the user rating of this work */ @Column({ nullable: true, }) public rating: number; /** * the release date of the work */ @Column({ nullable: true, }) public releaseDate: Date; /** * the languages of the work (if applicable) */ @ManyToMany(() => Language, (language: Language) => language.works) public languages: Promise; /** * the collections this work is a part of */ @OneToMany(() => CollectionPart, (collectionPart: CollectionPart) => collectionPart.work) public collectionParts: Promise; }