dont return unnecessary data

v1.18.x
barisusakli
parent a52c69d2a1
commit e2707353e9

@ -98,7 +98,7 @@ module.exports = function(db, module) {
module.isSetMember = function(key, value, callback) { module.isSetMember = function(key, value, callback) {
value = helpers.valueToString(value); 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); callback(err, item !== null && item !== undefined);
}); });
}; };
@ -108,7 +108,7 @@ module.exports = function(db, module) {
values[i] = helpers.valueToString(values[i]); 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) { if (err) {
return callback(err); return callback(err);
} }
@ -125,7 +125,7 @@ module.exports = function(db, module) {
value = helpers.valueToString(value); 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) { if(err) {
return callback(err); return callback(err);
} }
@ -143,13 +143,13 @@ module.exports = function(db, module) {
}; };
module.getSetMembers = function(key, callback) { 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 : []); callback(err, data ? data.members : []);
}); });
}; };
module.getSetsMembers = function(keys, callback) { 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) { if (err) {
return callback(err); return callback(err);
} }
@ -167,7 +167,7 @@ module.exports = function(db, module) {
}; };
module.setCount = function(key, callback) { 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); return callback(err, data ? data.members.length : 0);
}); });
}; };

Loading…
Cancel
Save