2020-04-10 05:02:19 +02:00
|
|
|
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
2020-04-10 04:04:13 +02:00
|
|
|
import { PercentCheck } from '../decorators/percent-check';
|
|
|
|
import { Tag } from './tag';
|
|
|
|
import { WorkCharacter } from './work-character';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This tag entity tags a character in a work.
|
|
|
|
*/
|
|
|
|
@Entity()
|
|
|
|
@PercentCheck('weight')
|
|
|
|
export class CharacterTag implements IIdentifiableEntity, IWeightedEntity {
|
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
public id: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the character ina work this tag describes
|
|
|
|
*/
|
|
|
|
@ManyToOne(
|
|
|
|
() => WorkCharacter,
|
|
|
|
(workCharacter: WorkCharacter) => workCharacter.characterTags,
|
|
|
|
{
|
|
|
|
nullable: false,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
public workCharacter: Promise<WorkCharacter>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the describing tag
|
|
|
|
*/
|
|
|
|
@ManyToOne(
|
|
|
|
() => Tag,
|
|
|
|
(tag: Tag) => tag.characterTags,
|
|
|
|
{
|
|
|
|
nullable: false,
|
|
|
|
onDelete: 'CASCADE',
|
|
|
|
onUpdate: 'CASCADE',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
public tag: Promise<Tag>;
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
public weight: number;
|
|
|
|
}
|