import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  OneToMany,
} from 'typeorm';
import { CategoryType } from '../../common/enums';
import { Channel } from '../../channels/entities/channel.entity';

@Entity('categories')
export class Category {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  name: string;

  @Column({ unique: true })
  slug: string;

  @Column({ nullable: true })
  icon: string | null;

  @Column({ type: 'enum', enum: CategoryType, default: CategoryType.ALL })
  type: CategoryType;

  @Column({ default: 0 })
  order: number;

  @OneToMany(() => Channel, (channel) => channel.category)
  channels: Channel[];
}
