31 lines
814 B
TypeScript
31 lines
814 B
TypeScript
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { PercentCheck } from '../decorators/percent-check';
|
|
import { Tag } from './tag';
|
|
import { Work } from './work';
|
|
|
|
@Entity()
|
|
@PercentCheck('weight')
|
|
export class WorkTag implements WorkTagEntityInterface {
|
|
@PrimaryGeneratedColumn()
|
|
public readonly id!: number;
|
|
|
|
@ManyToOne(() => Tag, (tag: TagEntityInterface) => tag.workTags, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public tag!: Promise<TagEntityInterface>;
|
|
|
|
@ManyToOne(() => Work, (work: WorkEntityInterface) => work.workTags, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public work!: Promise<WorkEntityInterface>;
|
|
|
|
@Column('int', {
|
|
nullable: true,
|
|
})
|
|
public weight!: number | null;
|
|
}
|