42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
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 IdentifiableEntityInterface, WeightedEntityInterface {
|
|
@PrimaryGeneratedColumn()
|
|
public id!: number;
|
|
|
|
/**
|
|
* the describing tag
|
|
*/
|
|
@ManyToOne(() => Tag, (tag: Tag) => tag.interactionTags, {
|
|
nullable: false,
|
|
onDelete: 'CASCADE',
|
|
onUpdate: 'CASCADE',
|
|
})
|
|
public tag!: Promise<Tag>;
|
|
|
|
/**
|
|
* the actors of this interaction
|
|
*/
|
|
@ManyToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.interactWith)
|
|
public subjectCharacters!: Promise<WorkCharacter[]>;
|
|
|
|
/**
|
|
* the receivers of this interaction
|
|
*/
|
|
@ManyToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.interactedBy)
|
|
public objectCharacters!: Promise<WorkCharacter[]>;
|
|
|
|
@Column('int', {
|
|
nullable: true,
|
|
})
|
|
public weight!: number | null;
|
|
}
|