Files
NodeBB/src/categories/delete.js

39 lines
873 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) {
2014-11-07 17:15:01 -05:00
batch.processSortedSet('cid:' + cid + ':tids', 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-11-07 17:15:01 -05:00
db.deleteAll([
'cid:' + cid + ':tids',
2015-01-08 13:47:15 -05:00
'cid:' + cid + ':tids:posts',
2014-11-07 17:15:01 -05:00
'cid:' + cid + ':pids',
'category:' + cid
], next);
}
], callback);
}
};