Files
NodeBB/src/categories/delete.js

34 lines
843 B
JavaScript
Raw Normal View History

'use strict';
var async = require('async'),
db = require('../database'),
2014-09-16 21:43:11 -04:00
batch = require('../batch'),
threadTools = require('../threadTools');
module.exports = function(Categories) {
Categories.purge = function(cid, callback) {
batch.processSortedSet('categories:' + cid + ':tid', function(tids, next) {
async.eachLimit(tids, 10, function(tid, next) {
threadTools.purge(tid, 0, next);
2014-09-16 21:43:11 -04:00
}, next);
}, {alwaysStartAt: 0}, function(err) {
2014-09-16 21:45:46 -04:00
if (err) {
return callback(err);
}
2014-09-16 21:43:11 -04:00
purgeCategory(cid, callback);
});
};
function purgeCategory(cid, callback) {
async.parallel([
function(next) {
db.sortedSetRemove('categories:cid', cid, next);
},
function(next) {
2014-09-16 21:43:11 -04:00
db.deleteAll(['categories:' + cid + ':tid', 'categories:recent_posts:cid:' + cid, 'category:' + cid], next);
}
], callback);
}
};