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

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

@Entity()
export class TagMultiName extends MultiName('Tag') {}
