import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { TransformationType } from './transformation-type'; import { Work } from './work'; /** * This entity describes how one work is transformed to another. */ @Entity() export class Transformation implements IIdentifiableEntity, IOrderableEntity { @PrimaryGeneratedColumn() public id!: number; /** * the work based on the original */ @ManyToOne(() => Work, (work: Work) => work.transformationOf, { nullable: false, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) public byWork!: Promise; /** * the transformation type */ @ManyToOne(() => TransformationType, (transformationType: TransformationType) => transformationType.transformations, { nullable: false, onDelete: 'RESTRICT', onUpdate: 'CASCADE', }) public type!: Promise; /** * the original work */ @ManyToOne(() => Work, (work: Work) => work.transformedBy, { nullable: false, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) public ofWork!: Promise; @Column({ nullable: false, default: 0, }) public order!: number; }