import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { PercentCheck } from '../decorators/percent-check'; import { Tag } from './tag'; import { WorkCharacter } from './work-character'; /** * This tag entity tags an interaction between two characters. */ @Entity() @PercentCheck('weight') export class InteractionTag implements IIdentifiableEntity, IWeightedEntity { @PrimaryGeneratedColumn() public id: number; /** * the describing tag */ @ManyToOne(() => Tag, (tag: Tag) => tag.interactionTags, { nullable: false, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) public tag: Promise; /** * the actors of this interaction */ @ManyToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.interactWith) public subjectCharacters: Promise; /** * the receivers of this interaction */ @ManyToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.interactedBy) public objectCharacters: Promise; @Column() public weight: number; }