import { Entity, JoinTable, ManyToMany, OneToMany } from 'typeorm'; import { Author } from './author'; import { MultiNamed } from './bases/multi-named'; import { Character } from './character'; import { Copy } from './copy'; import { Fiction } from './fiction'; import { Tag } from './tag'; @Entity() export class Book extends MultiNamed { @OneToMany(() => Copy, (copy: Copy) => copy.original, { nullable: false, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) public copies: Promise; @ManyToMany(() => Author, { nullable: true, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) @JoinTable() public authors: Promise; @ManyToMany(() => Fiction, { nullable: true, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) @JoinTable() public fictions: Promise; @ManyToMany(() => Character, { nullable: true, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) @JoinTable() public characters: Promise; @ManyToMany(() => Tag, { nullable: true, onDelete: 'CASCADE', onUpdate: 'CASCADE', }) @JoinTable() public tags: Promise; }