|
|
|
@ -98,7 +98,7 @@ module.exports = function(db, module) {
|
|
|
|
|
module.isSetMember = function(key, value, callback) {
|
|
|
|
|
value = helpers.valueToString(value);
|
|
|
|
|
|
|
|
|
|
db.collection('objects').findOne({_key:key, members: value}, function(err, item) {
|
|
|
|
|
db.collection('objects').findOne({_key:key, members: value}, {_id: 0, members: 0},function(err, item) {
|
|
|
|
|
callback(err, item !== null && item !== undefined);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
@ -108,7 +108,7 @@ module.exports = function(db, module) {
|
|
|
|
|
values[i] = helpers.valueToString(values[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.collection('objects').findOne({_key:key, members: {$in : values}}, function(err, items) {
|
|
|
|
|
db.collection('objects').findOne({_key: key, members: {$in : values}}, {_id: 0, _key: 0}, function(err, items) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
@ -125,7 +125,7 @@ module.exports = function(db, module) {
|
|
|
|
|
|
|
|
|
|
value = helpers.valueToString(value);
|
|
|
|
|
|
|
|
|
|
db.collection('objects').find({_key: {$in : sets}, members: value}).toArray(function(err, result) {
|
|
|
|
|
db.collection('objects').find({_key: {$in : sets}, members: value}, {_id:0, members: 0}).toArray(function(err, result) {
|
|
|
|
|
if(err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
@ -143,13 +143,13 @@ module.exports = function(db, module) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.getSetMembers = function(key, callback) {
|
|
|
|
|
db.collection('objects').findOne({_key:key}, {members:1}, function(err, data) {
|
|
|
|
|
db.collection('objects').findOne({_key: key}, {members: 1}, {_id: 0, _key: 0}, function(err, data) {
|
|
|
|
|
callback(err, data ? data.members : []);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.getSetsMembers = function(keys, callback) {
|
|
|
|
|
db.collection('objects').find({_key: {$in: keys}}, {_key: 1, members: 1}).toArray(function(err, data) {
|
|
|
|
|
db.collection('objects').find({_key: {$in: keys}}, {_id: 0, _key: 1, members: 1}).toArray(function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
@ -167,7 +167,7 @@ module.exports = function(db, module) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.setCount = function(key, callback) {
|
|
|
|
|
db.collection('objects').findOne({_key:key}, function(err, data) {
|
|
|
|
|
db.collection('objects').findOne({_key: key}, {_id: 0}, function(err, data) {
|
|
|
|
|
return callback(err, data ? data.members.length : 0);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|