44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Column, Entity, JoinTable, 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 IdentifiableEntityInterface, MultiNamedEntityInterface, HierarchicalEntityInterface<World> {
|
|
@PrimaryGeneratedColumn()
|
|
public id!: number;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: '',
|
|
})
|
|
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)
|
|
@JoinTable()
|
|
public worldCharacters!: Promise<WorldCharacter[]>;
|
|
|
|
@ManyToMany(() => World, (world: World) => world.parents)
|
|
public children!: Promise<World[]>;
|
|
|
|
@ManyToMany(() => World, (world: World) => world.children)
|
|
@JoinTable()
|
|
public parents!: Promise<World[]>;
|
|
}
|