ADD: delete a category by id logic function
This commit is contained in:
@@ -29,3 +29,13 @@ module.exports.updateCategory = async (categoryId, data) => {
|
|||||||
|
|
||||||
return category
|
return category
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.deleteCategory = async (categoryId) => {
|
||||||
|
const category = await Category.findByIdAndDelete(categoryId)
|
||||||
|
|
||||||
|
if (!category) {
|
||||||
|
throw new AppError('NoCategoryFound', 404, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user