49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
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 IdentifiableEntityInterface, OrderableEntityInterface {
|
|
@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<Work>;
|
|
|
|
/**
|
|
* the transformation type
|
|
*/
|
|
@ManyToOne(() => TransformationType, (transformationType: TransformationType) => transformationType.transformations, {
|
|
nullable: false,
|
|
onDelete: 'RESTRICT',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public type!: Promise<TransformationType>;
|
|
|
|
/**
|
|
* the original work
|
|
*/
|
|
@ManyToOne(() => Work, (work: Work) => work.transformedBy, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public ofWork!: Promise<Work>;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: 0,
|
|
})
|
|
public order!: number;
|
|
}
|