diff --git a/src/categories/update.js b/src/categories/update.js index e103d3e5dc..f68a7aed20 100644 --- a/src/categories/update.js +++ b/src/categories/update.js @@ -11,12 +11,18 @@ module.exports = function(Categories) { Categories.update = function(modified, callback) { function updateCategory(cid, next) { - var category = modified[cid]; - var fields = Object.keys(category); - - async.each(fields, function(key, next) { - updateCategoryField(cid, key, category[key], next); - }, next); + Categories.exists(cid, function(err, exists) { + if (err || !exists) { + return next(err); + } + + var category = modified[cid]; + var fields = Object.keys(category); + + async.each(fields, function(key, next) { + updateCategoryField(cid, key, category[key], next); + }, next); + }); } var cids = Object.keys(modified);