import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { VehicleModEntity } from './vehicle-mod.entity';
import { VehicleEntity } from './vehicle.entity';

@Entity('vehicle_vehicle_mods')
export class VehicleVehicleModEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'int' }) vehicle_id: number;
    @Column({ type: 'int' }) vehicle_mod_id: number;

    @ManyToOne(() => VehicleEntity, (vehicle) => vehicle.mods)
    @JoinColumn({ name: 'vehicle_id' })
    vehicle: VehicleEntity;

    @OneToOne(() => VehicleModEntity)
    @JoinColumn({
        name: 'vehicle_mod_id',
        referencedColumnName: 'id',
    })
    mod: VehicleModEntity;
}
