import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Author } from './author';

@Entity()
export class AuthorName implements IIdentifiableEntity, INameEntity {
  @PrimaryGeneratedColumn()
  public id!: number;

  @ManyToOne(() => Author, (author: Author) => author.names, {
    nullable: false,
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  public entity!: Promise<Author>;

  @Column({
    nullable: false,
    default: '',
  })
  public name!: string;
}
