import { WebBid } from '@/modules/bids/entities/wed-bid.entity';
import {
  Column,
  Entity,
  JoinColumn,
  OneToMany,
  OneToOne,
  PrimaryGeneratedColumn,
  Unique,
} from 'typeorm';
import { ScrapItem } from './scrap-item.entity';
import { Timestamp } from './timestamp';

@Entity('scrap-configs')
export class ScrapConfig extends Timestamp {
  @PrimaryGeneratedColumn('increment')
  id: number;

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

  @Column({ default: 'cisco' })
  keywords: string;

  @Column({ default: true })
  enable: boolean;

  @OneToOne(() => WebBid, (web) => web.scrap_config, { onDelete: 'CASCADE' })
  @JoinColumn()
  web_bid: WebBid;

  @OneToMany(() => ScrapItem, (web) => web.scrap_config, {
    onDelete: 'CASCADE',
  })
  scrap_items: ScrapItem[];
}
