import roleModel from "./role.model";
import { IRole } from "./role.interface";

export class RoleService {
    async getAll() {

        return await roleModel.find();
    }

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

    async create(
        data:IRole
    ) {
        return await roleModel.create(data);
    }

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

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