import vehicleassigModel from "./vehicleassig.model";

export class VehicleAssigService {

    async getAll()
    {
        return await vehicleassigModel
        .find()
        .populate(
            "createdBy",
            "userName"
        );
    }

    async getById(
        id:string
    ){
        return await vehicleassigModel
        .findById(id)
        .populate(
            "createdBy",
            "userName"
        );
    }

    async create(
        data:any
    ){

        return await vehicleassigModel.create(
            data
        );
    }

    async update(
        id:string,
        data:any
    ){
        return await vehicleassigModel.findByIdAndUpdate(
            id,
            data,
            {
                new:true
            }
        );
    }

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