55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { Column, Entity, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { WorkCharacter } from './work-character';
|
|
import { World } from './world';
|
|
import { WorldCharacterName } from './world-character-name';
|
|
|
|
/**
|
|
* This entity describes a canon character in a fictional world.
|
|
*/
|
|
@Entity()
|
|
export class WorldCharacter implements IIdentifiableEntity, IMultiNamedEntity, IHierachicalEntity<WorldCharacter> {
|
|
@PrimaryGeneratedColumn()
|
|
public id: number;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
})
|
|
public nameCanonical: string;
|
|
|
|
@OneToMany(
|
|
() => WorldCharacterName,
|
|
(worldCharacterName: WorldCharacterName) => worldCharacterName.entity
|
|
)
|
|
public names: Promise<WorldCharacterName[]>;
|
|
|
|
/**
|
|
* the characters in works which are based on this one
|
|
*/
|
|
@ManyToMany(
|
|
() => WorkCharacter,
|
|
(workCharacter: WorkCharacter) => workCharacter.worldCharacters
|
|
)
|
|
public workCharacters: Promise<WorkCharacter[]>;
|
|
|
|
/**
|
|
* the fictional worlds this character is a part of
|
|
*/
|
|
@ManyToMany(
|
|
() => World,
|
|
(world: World) => world.worldCharacters
|
|
)
|
|
public worlds: Promise<World[]>;
|
|
|
|
@ManyToMany(
|
|
() => WorldCharacter,
|
|
(worldCharacter: WorldCharacter) => worldCharacter.children
|
|
)
|
|
public parents: Promise<WorldCharacter[]>;
|
|
|
|
@ManyToMany(
|
|
() => WorldCharacter,
|
|
(worldCharacter: WorldCharacter) => worldCharacter.parents
|
|
)
|
|
public children: Promise<WorldCharacter[]>;
|
|
}
|