ADD: update a category by id logic

This commit is contained in:
MohammadHMazarei
2024-12-29 20:04:44 +03:30
parent 6675a9d36a
commit 9d99b89232
+10
View File
@@ -19,3 +19,13 @@ module.exports.getCategory = async (categoryId) => {
return category 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
}