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

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

@Entity()
export class AuthorMultiName extends MultiName('Author') {}
