import { Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
import { CompanyEntity } from './company.entity';

@Entity('contracts')
export class GovernmentContractEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 64 }) name: string;
    @Column({ type: 'text' }) description: string;
    @Column({ type: 'json', nullable: true }) data: null | {
        trucking?: {
            cdl_level: number;
        };
    };

    @ManyToMany(() => CompanyEntity, (company) => company.contracts)
    @JoinTable({
        name: 'company_contracts',
        joinColumn: { name: 'contract_id' },
        inverseJoinColumn: { name: 'company_id' },
    })
    companies: CompanyEntity[];
}
