55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
import { Column, Entity, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { Work } from './work';
|
|
import { WorldCharacter } from './world-character';
|
|
import { WorldName } from './world-name';
|
|
|
|
/**
|
|
* This entity describes a fictional world.
|
|
*/
|
|
@Entity()
|
|
export class World implements IIdentifiableEntity, IMultiNamedEntity, IHierachicalEntity<World> {
|
|
@PrimaryGeneratedColumn()
|
|
public id: number;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
})
|
|
public nameCanonical: string;
|
|
|
|
@OneToMany(
|
|
() => WorldName,
|
|
(worldName: WorldName) => worldName.entity
|
|
)
|
|
public names: Promise<WorldName[]>;
|
|
|
|
/**
|
|
* works taking place in this world
|
|
*/
|
|
@ManyToMany(
|
|
() => Work,
|
|
(work: Work) => work.worlds
|
|
)
|
|
public works: Promise<Work[]>;
|
|
|
|
/**
|
|
* canon characters in this world
|
|
*/
|
|
@ManyToMany(
|
|
() => WorldCharacter,
|
|
(worldCharacter: WorldCharacter) => worldCharacter.worlds
|
|
)
|
|
public worldCharacters: Promise<WorldCharacter[]>;
|
|
|
|
@ManyToMany(
|
|
() => World,
|
|
(world: World) => world.parents
|
|
)
|
|
public children: Promise<World[]>;
|
|
|
|
@ManyToMany(
|
|
() => World,
|
|
(world: World) => world.children
|
|
)
|
|
public parents: Promise<World[]>;
|
|
}
|