recursively get all children
calculate topic/post count from children
new sorted set `cid:<id>:children`
fix search query params
This commit is contained in:
barisusakli
2015-08-18 14:17:16 -04:00
parent a990e9c3bf
commit 5b87af4389
12 changed files with 181 additions and 43 deletions

View File

@@ -30,15 +30,32 @@ module.exports = function(Categories) {
function(next) {
db.sortedSetRemove('categories:cid', cid, next);
},
function(next) {
removeFromParent(cid, next);
},
function(next) {
db.deleteAll([
'cid:' + cid + ':tids',
'cid:' + cid + ':tids:posts',
'cid:' + cid + ':pids',
'cid:' + cid + ':read_by_uid',
'cid:' + cid + ':children',
'category:' + cid
], next);
}
], callback);
}
function removeFromParent(cid, callback) {
async.waterfall([
function(next) {
Categories.getCategoryField(cid, 'parentCid', next);
},
function(parentCid, next) {
parentCid = parseInt(parentCid, 10) || 0;
db.sortedSetRemove('cid:' + parentCid + ':children', cid, next);
}
], callback);
}
};