RenaiApp/src/main/entities/library/world.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

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 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)
@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[]>;
}