import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { ItemTypeGroupItemTypeEntity } from './item-type-group-item-type.entity';
import { ItemTypeEntity } from './item-type.entity';

@Entity('item_type_groups')
export class ItemTypeGroupEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 30 }) name: string;

    @ManyToMany(() => ItemTypeEntity, {
        eager: true,
    })
    @JoinTable({
        name: 'item_type_group_item_types',
        joinColumn: { name: 'item_group_id' },
        inverseJoinColumn: { name: 'item_type_id' },
    })
    items: ItemTypeEntity[];
}
