import AppError from "../../errors/AppError"; import SchedulingNotify from "../../models/SchedulingNotify"; interface SchedulingData { name?: string } interface Request { schedulingData: SchedulingData schedulingDataId: string } const UpdateSchedulingNotify = async ({ schedulingData, schedulingDataId }: Request): Promise => { const { name } = schedulingData; const updateScheduling = await SchedulingNotify.findOne({ where: { id: schedulingDataId }, attributes: ["id", "name"] }); if (!updateScheduling) { //console.log('NOT FOUND SCHEDULING NOTIFY') throw new AppError("ERR_NO_SCHEDULING_NOTIFY_FOUND", 404); } await updateScheduling.update({ name }); await updateScheduling.reload({ attributes: ["id", "name"] }); return updateScheduling; }; export default UpdateSchedulingNotify;