31 lines
907 B
TypeScript
31 lines
907 B
TypeScript
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { PercentCheck } from '../decorators/percent-check';
|
|
import { Tag } from './tag';
|
|
import { WorkCharacter } from './work-character';
|
|
|
|
@Entity()
|
|
@PercentCheck('weight')
|
|
export class CharacterTag implements CharacterTagEntityInterface {
|
|
@PrimaryGeneratedColumn()
|
|
public readonly id!: number;
|
|
|
|
@ManyToOne(() => WorkCharacter, (workCharacter: WorkCharacterEntityInterface) => workCharacter.characterTags, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public workCharacter!: Promise<WorkCharacterEntityInterface>;
|
|
|
|
@ManyToOne(() => Tag, (tag: TagEntityInterface) => tag.characterTags, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public tag!: Promise<TagEntityInterface>;
|
|
|
|
@Column('int', {
|
|
nullable: true,
|
|
})
|
|
public weight!: number | null;
|
|
}
|