import { Column, Entity, ManyToOne, PrimaryGeneratedColumn, JoinColumn, OneToMany, OneToOne } from 'typeorm';
import { FurnitureCategoryEntity } from './furniture-category.entity';
import { FurnitureHashTagEntity } from './furniture-hash-tags.entity';

@Entity('furniture_models')
export class FurnitureModelEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 100 }) hash: string;
    @Column({ type: 'varchar', length: 100 }) name: string;
    @Column() category_id: number;
    @Column() price: number;
    @Column({ nullable: true }) inventory_capacity: number;

    @ManyToOne(() => FurnitureCategoryEntity, (category) => category.models)
    @JoinColumn({ name: 'category_id' })
    category: FurnitureCategoryEntity;

    @OneToOne(() => FurnitureHashTagEntity, { nullable: true, eager: true })
    @JoinColumn({
        name: 'hash',
        referencedColumnName: 'hash',
    })
    hashtag: FurnitureHashTagEntity | null;
}
