diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index 2308892a42..8471bd9c0a 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -10,8 +10,8 @@ module.exports = function(db, module) { if (!key) { return callback(); } - data._key = key; - db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, function(err) { + + db.collection('objects').update({_key: key}, {$set: data}, {upsert: true, w: 1}, function(err) { callback(err); }); }; @@ -27,7 +27,7 @@ module.exports = function(db, module) { if (!key) { return callback(); } - db.collection('objects').findOne({_key: key}, {_id:0, _key:0}, callback); + db.collection('objects').findOne({_key: key}, {_id: 0, _key: 0}, callback); }; module.getObjects = function(keys, callback) { @@ -198,7 +198,7 @@ module.exports = function(db, module) { field = helpers.fieldToString(field); data[field] = value; - db.collection('objects').findAndModify({_key: key}, {}, {$inc: data}, {new:true, upsert:true}, function(err, result) { + db.collection('objects').findAndModify({_key: key}, {}, {$inc: data}, {new: true, upsert: true}, function(err, result) { callback(err, result ? result[field] : null); }); }; diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 86beb9bf29..a4f836621e 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -15,12 +15,8 @@ module.exports = function(db, module) { } value = helpers.valueToString(value); - var data = { - score: parseInt(score, 10), - value: value - }; - db.collection('objects').update({_key: key, value: value}, {$set: data}, {upsert:true, w: 1}, function(err) { + db.collection('objects').update({_key: key, value: value}, {$set: {score: parseInt(score, 10)}}, {upsert:true, w: 1}, function(err) { callback(err); }); }; @@ -38,7 +34,7 @@ module.exports = function(db, module) { var bulk = db.collection('objects').initializeUnorderedBulkOp(); for(var i=0; i