From 76037a5f14d006c055008fb048d506d491bb125d Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 11 Mar 2014 14:43:08 -0400 Subject: [PATCH] closes #1191 added a new method called isSetMembers takes in an array of values to test if they are members of a set --- src/categories.js | 8 +------- src/database/mongo.js | 18 ++++++++++++++++++ src/database/redis.js | 24 +++++++++++++++++++++--- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/categories.js b/src/categories.js index ba772bb5c1..24efbc4f16 100644 --- a/src/categories.js +++ b/src/categories.js @@ -217,13 +217,7 @@ var db = require('./database'), }; Categories.hasReadCategory = function(cid, uid, callback) { - db.isSetMember('cid:' + cid + ':read_by_uid', uid, function(err, hasRead) { - if(err) { - return callback(false); - } - - callback(hasRead); - }); + db.isSetMember('cid:' + cid + ':read_by_uid', uid, callback); }; Categories.getRecentReplies = function(cid, uid, count, callback) { diff --git a/src/database/mongo.js b/src/database/mongo.js index 92a80cebf7..8c2d527309 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -469,6 +469,24 @@ }); }; + module.isSetMembers = function(key, values, callback) { + for (var i=0; i