import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { World } from './world';

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

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

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