waterfall

v1.18.x
barisusakli 10 years ago
parent 414c2a8bd9
commit 83ad4ab042

@ -206,19 +206,17 @@ module.exports = function(Topics) {
Topics.updateTags = function(tid, tags, callback) { Topics.updateTags = function(tid, tags, callback) {
callback = callback || function() {}; callback = callback || function() {};
Topics.getTopicField(tid, 'timestamp', function(err, timestamp) { async.waterfall([
if (err) { function(next) {
return callback(err); Topics.deleteTopicTags(tid, next);
},
function(next) {
Topics.getTopicField(tid, 'timestamp', next);
},
function(timestamp, next) {
Topics.createTags(tags, tid, timestamp, next);
} }
], callback);
Topics.deleteTopicTags(tid, function(err) {
if (err) {
return callback(err);
}
Topics.createTags(tags, tid, timestamp, callback);
});
});
}; };
Topics.deleteTopicTags = function(tid, callback) { Topics.deleteTopicTags = function(tid, callback) {
@ -243,7 +241,9 @@ module.exports = function(Topics) {
updateTagCount(tag, next); updateTagCount(tag, next);
}, next); }, next);
} }
], callback); ], function(err, results) {
callback(err);
});
}); });
}; };

Loading…
Cancel
Save