moved debugs 1 level up increased key limit to 100

v1.18.x
barisusakli 11 years ago
parent 57e204df8e
commit fe58ea55d4

@ -23,7 +23,10 @@ module.exports = function(db, module) {
};
module.getObjects = function(keys, callback) {
helpers.checkKeys(keys);
if (keys.length > helpers.KEY_LIMIT) {
var e = new Error('too many keys');
winston.warn('[HASH - TOO_MANY_KEYS] ' + keys.length + ' ' + keys[0] + ' ' + keys[keys.length - 1] + '\n', e.stack);
}
db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function(err, data) {
if(err) {
return callback(err);
@ -54,7 +57,11 @@ module.exports = function(db, module) {
};
module.getObjectsFields = function(keys, fields, callback) {
helpers.checkKeys(keys);
if (keys.length > helpers.KEY_LIMIT) {
var e = new Error('too many keys');
winston.warn('[HASH - TOO_MANY_KEYS] ' + keys.length + ' ' + keys[0] + ' ' + keys[keys.length - 1] + '\n', e.stack);
}
var _fields = {
_id: 0,
_key: 1

@ -9,7 +9,7 @@ helpers.toMap = function(data) {
map[data[i]._key] = data[i];
}
return map;
}
};
helpers.fieldToString = function(field) {
if(field === null || field === undefined) {
@ -34,16 +34,6 @@ helpers.valueToString = function(value) {
helpers.noop = function() {};
helpers.checkKeys = function(keys) {
if (!Array.isArray(keys)) {
var e = new Error('invalid keys');
winston.warn('[INVALID_KEYS] ', e.stack);
return;
}
if (keys.length > 50) {
var e = new Error('too many keys');
winston.warn('[TOO_MANY_KEYS] ' + keys.length + ' ' + keys[0] + ' ' + keys[keys.length - 1] + '\n', e.stack);
}
}
helpers.KEY_LIMIT = 100;
module.exports = helpers;

@ -96,6 +96,10 @@ module.exports = function(db, module) {
};
module.getSetsMembers = function(keys, callback) {
if (keys.length > helpers.KEY_LIMIT) {
var e = new Error('too many keys');
winston.warn('[SET - TOO_MANY_KEYS] ' + keys.length + ' ' + keys[0] + ' ' + keys[keys.length - 1] + '\n', e.stack);
}
db.collection('objects').find({_key: {$in: keys}}, {_key: 1, members: 1}).toArray(function(err, data) {
if (err) {
return callback(err);

Loading…
Cancel
Save