added a new method called isSetMembers takes in an array of values to
test if they are members of a set
This commit is contained in:
barisusakli
2014-03-11 14:43:08 -04:00
parent 29ad8d2582
commit 76037a5f14
3 changed files with 43 additions and 13 deletions

View File

@@ -469,6 +469,24 @@
});
};
module.isSetMembers = function(key, values, callback) {
for (var i=0; i<values.length; ++i) {
values[i] = toString(values[i]);
}
db.collection('objects').findOne({_key:key, members: {$in : values}}, function(err, items) {
if (err) {
return callback(err);
}
values = values.map(function(value) {
return items.members.indexOf(value) !== -1
});
callback(null, values);
});
};
module.isMemberOfSets = function(sets, value, callback) {
value = toString(value);