diff --git a/components/category/categoryService.js b/components/category/categoryService.js index fd37141..505953e 100644 --- a/components/category/categoryService.js +++ b/components/category/categoryService.js @@ -19,3 +19,13 @@ module.exports.getCategory = async (categoryId) => { return category } + +module.exports.updateCategory = async (categoryId, data) => { + const category = await Category.findOneAndUpdate({ _id: categoryId }, data, { new: true }) + + if (!category) { + throw new AppError('NoCategoryFound', 404, {}) + } + + return category +}