RenaiApp/src/main/entities/library/transformation.ts

41 lines
1.0 KiB
TypeScript

import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { TransformationType } from './transformation-type';
import { Work } from './work';
@Entity()
export class Transformation implements TransformationEntityInterface {
@PrimaryGeneratedColumn()
public readonly id!: number;
@ManyToOne(() => Work, (work: Work) => work.transformationOf, {
nullable: false,
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
public byWork!: Promise<Work>;
@ManyToOne(
() => TransformationType,
(transformationType: TransformationTypeEntityInterface) => transformationType.transformations,
{
nullable: false,
onDelete: 'RESTRICT',
onUpdate: 'CASCADE',
}
)
public type!: Promise<TransformationTypeEntityInterface>;
@ManyToOne(() => Work, (work: WorkEntityInterface) => work.transformedBy, {
nullable: true,
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
public ofWork!: Promise<WorkEntityInterface> | null;
@Column({
nullable: false,
default: 0,
})
public order!: number;
}