import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { ItemTypeEntity } from './item-type.entity';
import { ItemTypeGroupEntity } from './item-type-groups.entity';

@Entity('item_type_group_item_types')
export class ItemTypeGroupItemTypeEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) item_group_id: number;
    @Column({ type: 'int' }) item_type_id: number;

    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP()' }) added_on: Date;
    @Column({ type: 'int' }) added_by: number;

    @ManyToOne(() => ItemTypeGroupEntity, (group) => group.items)
    @JoinColumn({ name: 'item_group_id' })
    group: ItemTypeGroupEntity;

    @OneToOne(() => ItemTypeEntity)
    @JoinColumn({
        name: 'item_type_id',
        referencedColumnName: 'id',
    })
    item_type: ItemTypeEntity;
}
