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);
},
function (next) {
async.eachSeries(privileges.privilegeList, function (privilege, next) {
groups.destroy('cid:' + cid + ':privileges:' + privilege, next);
}, next);
groups.destroy(privileges.privilegeList.map(function (privilege) {
return 'cid:' + cid + ':privileges:' + privilege;
}), next);
},
], function (err) {
callback(err);

@ -96,16 +96,10 @@ function deleteUserNids(nids, uid, callback) {
if (!nids.length) {
return setImmediate(callback);
}
async.parallel([
function (next) {
db.sortedSetRemove('uid:' + uid + ':notifications:read', nids, next);
},
function (next) {
db.sortedSetRemove('uid:' + uid + ':notifications:unread', nids, next);
},
], function (err) {
callback(err);
});
db.sortedSetRemove([
'uid:' + uid + ':notifications:read',
'uid:' + uid + ':notifications:unread',
], nids, 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 () {

Loading…
Cancel
Save