import { CharacterTag } from './character-tag'; import { InteractionTag } from './interaction-tag'; import { TagName } from './tag-name'; import { WorkTag } from './work-tag'; import { Column, Entity, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; /** * This entity is the main tag entity. * Tags have a name and a description. * They can tag a work, a character, or a character interaction. * They can also be in a hierarchy */ @Entity() export class Tag implements IIdentifiableEntity, IMultiNamedEntity, IDescribableEntity, IHierachicalEntity { @PrimaryGeneratedColumn() public id: number; @Column({ nullable: false, }) public nameCanonical: string; @OneToMany( () => TagName, (tagName: TagName) => tagName.entity ) public names: Promise; /** * this tag tagging a work */ @OneToMany( () => WorkTag, (workTag: WorkTag) => workTag.tag ) public workTags: Promise; /** * this tag tagging characters */ @OneToMany( () => CharacterTag, (characterTag: CharacterTag) => characterTag.tag ) public characterTags: Promise; /** * this tag tagging a character interaction */ @OneToMany( () => InteractionTag, (interactionTag: InteractionTag) => interactionTag.tag ) public interactionTags: Promise; @ManyToMany( () => Tag, (tag: Tag) => tag.children ) public parents: Promise; @ManyToMany( () => Tag, (tag: Tag) => tag.parents ) public children: Promise; @Column({ nullable: true, }) public description: string; }