import { Entity, ManyToMany } from 'typeorm';
import { BaseEntity } from '../base-entity';
import { MultiName, MultiNamed } from './base/multi-named';
import { Book } from './book';
import { Character } from './character';

@Entity()
export class Fiction extends MultiNamed(BaseEntity, 'FictionMultiName') {
  @ManyToMany(() => Book, {
    nullable: false,
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  public books: Promise<Book[]>;

  @ManyToMany(() => Character, {
    nullable: true,
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  public characters: Promise<Character[]>;
}

@Entity()
export class FictionMultiName extends MultiName('Fiction') {}
