diff --git a/src/database/mongo.js b/src/database/mongo.js index 801abb6dd7..d0768ccba7 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -32,6 +32,7 @@ db.createCollection('sets', function(err, collection) { }); + callback(err); }); // look up how its done in mongo @@ -74,20 +75,27 @@ //hashes module.setObject = function(key, data, callback) { + console.log('SET OBJECT CALLED', key, data); data['_key'] = key; - db.collection('objects').insert(data, {w:1}, function(err, result) { + db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, function(err, result) { + console.log('SET OBJECT COMPLETE', err, result); callback(err, result); }); } module.setObjectField = function(key, field, value, callback) { - db.collection('objects').update(); + var data = {}; + data[field] = value; + db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, function(err, result) { + console.log('SET OBJECT COMPLETE', err, result); + callback(err, result); + }); } module.getObject = function(key, callback) { - console.log('calling findOne'); + console.log('GET OBJECT', key); db.collection('objects').findOne({_key:key}, function(err, item) { - console.log(item); + console.log('RETURNING OBJECT', item); callback(err, item); }); } @@ -106,7 +114,7 @@ var _fields = {}; for(var i=0; i