import fuelTypeModel from "./fuelType.model";
import { IFuelType } from "./fuelType.interface";

export class FuelTypeService {

    //Obtener datos

    async getAll() {
        return await fuelTypeModel.find();
    }

    //Obtener por id

    async getById(
        id:string
    ){
        return fuelTypeModel.findById(
            id
        );
    }

    //Crear

    async create (
        data:IFuelType
    ) {
        return await fuelTypeModel.create(
            data
        );
    }

    //Actualizar
    async update(
        id:string,
        data:Partial<IFuelType>
    ) {
        return await fuelTypeModel.findByIdAndUpdate (
            id,
            data,
            {
                new:true
            }
        );
    }

    //Eliminar

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