pass array to groups.destroy

pass array to db.sortedSetRemove
v1.18.x
Barış Soner Uşaklı 7 years ago
parent 55b872fe3e
commit fde44cb9b9

@ -58,9 +58,9 @@ module.exports = function (Categories) {
], next); ], next);
}, },
function (next) { function (next) {
async.eachSeries(privileges.privilegeList, function (privilege, next) { groups.destroy(privileges.privilegeList.map(function (privilege) {
groups.destroy('cid:' + cid + ':privileges:' + privilege, next); return 'cid:' + cid + ':privileges:' + privilege;
}, next); }), next);
}, },
], function (err) { ], function (err) {
callback(err); callback(err);

@ -96,16 +96,10 @@ function deleteUserNids(nids, uid, callback) {
if (!nids.length) { if (!nids.length) {
return setImmediate(callback); return setImmediate(callback);
} }
async.parallel([ db.sortedSetRemove([
function (next) { 'uid:' + uid + ':notifications:read',
db.sortedSetRemove('uid:' + uid + ':notifications:read', nids, next); 'uid:' + uid + ':notifications:unread',
}, ], nids, callback);
function (next) {
db.sortedSetRemove('uid:' + uid + ':notifications:unread', nids, next);
},
], function (err) {
callback(err);
});
} }
function getNotifications(uid, start, stop, callback) { function getNotifications(uid, start, stop, callback) {

@ -678,6 +678,26 @@ describe('Sorted Set methods', function () {
}); });
}); });
}); });
it('should remove multiple values from multiple keys', function (done) {
db.sortedSetAdd('multiTest5', [1], ['one'], function (err) {
assert.ifError(err);
db.sortedSetAdd('multiTest6', [2], ['two'], function (err) {
assert.ifError(err);
db.sortedSetAdd('multiTest7', [3], ['three'], function (err) {
assert.ifError(err);
db.sortedSetRemove(['multiTest5', 'multiTest6', 'multiTest7'], ['one', 'two', 'three'], function (err) {
assert.ifError(err);
db.getSortedSetsMembers(['multiTest5', 'multiTest6', 'multiTest7'], function (err, members) {
assert.ifError(err);
assert.deepEqual(members, [[], [], []]);
done();
});
});
});
});
});
});
}); });
describe('sortedSetsRemove()', function () { describe('sortedSetsRemove()', function () {

Loading…
Cancel
Save