import vehiclesConfigModel from "./vehiclesConfig.model";
import { IVehicleConfig } from "./vehiclesConfig.interface";

export class VehicleConfigService {

    async getAll()
    {
        return await vehiclesConfigModel
        .find()
        .populate("fuelTypeId");   
    }

    async getById(
        id:string
    )
    {
        return await vehiclesConfigModel
        .findById(id)
        .populate("fuelTypeId");
    }

    async create(
        data:IVehicleConfig
    ){
        return await vehiclesConfigModel.create(
            data);
    }

    async update(
        id:string,
        data:Partial<IVehicleConfig>
    ){
        return await vehiclesConfigModel.findByIdAndUpdate(
            id,
            data,
            {
                new:true
            }
        );
    }

    async delete(
        id:string
    ){
        return await vehiclesConfigModel.findByIdAndDelete(
            id
        );
    }
}