import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { ItemCategoryEntity } from '../../domain/entities/item-category.entity';
import { Column, Entity, OneToMany } from 'typeorm';
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
import { ItemType } from '../../constants';
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';

@Entity(TABLE_NAME.ITEM_CATEGORY)
export class ItemCategoryModel
  extends BaseStatusModel<ItemCategoryEntity>
  implements ItemCategoryEntity
{
  @Column('varchar', { name: 'name' })
  name: string;

  @Column('enum', {
    name: 'item_type',
    enum: ItemType,
    default: ItemType.TIKET_MASUK,
  })
  item_type: ItemType;

  @OneToMany(() => ItemModel, (model) => model.item_category, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  items: ItemModel[];
}
