2020-04-10 05:02:19 +02:00
|
|
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
2020-04-10 04:04:13 +02:00
|
|
|
import { TransformationType } from './transformation-type';
|
|
|
|
import { Work } from './work';
|
|
|
|
|
|
|
|
@Entity()
|
2021-01-24 19:11:45 +01:00
|
|
|
export class Transformation implements TransformationEntityInterface {
|
2020-04-10 04:04:13 +02:00
|
|
|
@PrimaryGeneratedColumn()
|
2021-01-24 19:11:45 +01:00
|
|
|
public readonly id!: number;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
2020-04-10 05:12:14 +02:00
|
|
|
@ManyToOne(() => Work, (work: Work) => work.transformationOf, {
|
|
|
|
nullable: false,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
2020-07-25 02:02:37 +02:00
|
|
|
public byWork!: Promise<Work>;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
2021-01-24 19:11:45 +01:00
|
|
|
@ManyToOne(
|
|
|
|
() => TransformationType,
|
|
|
|
(transformationType: TransformationTypeEntityInterface) => transformationType.transformations,
|
|
|
|
{
|
|
|
|
nullable: false,
|
|
|
|
onDelete: 'RESTRICT',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
public type!: Promise<TransformationTypeEntityInterface>;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
2021-01-24 19:11:45 +01:00
|
|
|
@ManyToOne(() => Work, (work: WorkEntityInterface) => work.transformedBy, {
|
|
|
|
nullable: true,
|
2020-04-10 05:12:14 +02:00
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
})
|
2021-01-24 19:11:45 +01:00
|
|
|
public ofWork!: Promise<WorkEntityInterface> | null;
|
2020-04-10 04:04:13 +02:00
|
|
|
|
|
|
|
@Column({
|
|
|
|
nullable: false,
|
|
|
|
default: 0,
|
|
|
|
})
|
2020-07-25 02:02:37 +02:00
|
|
|
public order!: number;
|
2020-04-10 04:04:13 +02:00
|
|
|
}
|