v1.18.x
barisusakli 10 years ago
parent 03ae7db561
commit e46cda835a

@ -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);

Loading…
Cancel
Save