34 lines
1.1 KiB
TypeScript
34 lines
1.1 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';
|
|
|
|
@Entity()
|
|
export class World implements WorldEntityInterface {
|
|
@PrimaryGeneratedColumn()
|
|
public readonly id!: number;
|
|
|
|
@Column({
|
|
nullable: false,
|
|
default: '',
|
|
})
|
|
public nameCanonical!: string;
|
|
|
|
@OneToMany(() => WorldName, (worldName: WorldNameEntityInterface) => worldName.entity)
|
|
public names!: Promise<WorldNameEntityInterface[]>;
|
|
|
|
@ManyToMany(() => Work, (work: WorkEntityInterface) => work.worlds)
|
|
public works!: Promise<WorkEntityInterface[]>;
|
|
|
|
@ManyToMany(() => WorldCharacter, (worldCharacter: WorldCharacterEntityInterface) => worldCharacter.worlds)
|
|
@JoinTable()
|
|
public worldCharacters!: Promise<WorldCharacterEntityInterface[]>;
|
|
|
|
@ManyToMany(() => World, (world: WorldEntityInterface) => world.parents)
|
|
public children!: Promise<WorldEntityInterface[]>;
|
|
|
|
@ManyToMany(() => World, (world: WorldEntityInterface) => world.children)
|
|
@JoinTable()
|
|
public parents!: Promise<WorldEntityInterface[]>;
|
|
}
|