completed hashes in mongodb I hope :)

v1.18.x
Baris Soner Usakli 11 years ago
parent 66bc4184d8
commit 610d45bb32

@ -163,21 +163,27 @@
var data = {}; var data = {};
data[field] = ""; data[field] = "";
db.collection('objects').update({_key:key}, {$unset : data}, function(err, result) { db.collection('objects').update({_key:key}, {$unset : data}, function(err, result) {
console.log(err, result);
callback(err, result); callback(err, result);
}); });
} }
module.incrObjectField = function(key, field, callback) { module.incrObjectField = function(key, field, callback) {
throw new Error('not-implemented'); module.incrObjectFieldBy(key, field, 1, callback);
} }
module.decrObjectField = function(key, field, callback) { module.decrObjectField = function(key, field, callback) {
throw new Error('not-implemented'); module.incrObjectFieldBy(key, field, -1, callback);
} }
module.incrObjectFieldBy = function(key, field, value, callback) { module.incrObjectFieldBy = function(key, field, value, callback) {
throw new Error('not-implemented'); var data = {};
data[field] = value;
db.collection('objects').update({_key:key}, {$inc : data}, function(err, result) {
console.log('incrObjectFieldBy', err, result);
module.getObjectField(key, field, function(err, value) {
callback(err, value);
});
});
} }

@ -141,6 +141,13 @@ var DebugRoute = function(app) {
}); });
} }
function incrObjectFieldBy(callback) {
db.incrObjectFieldBy(objectKey, 'age', 3, function(err, data) {
console.log('incrObjectFieldBy return', data);
callback(err, {'incrObjectFieldBy':data});
});
}
var tasks = [ var tasks = [
setObject, setObject,
getObject, getObject,
@ -153,7 +160,9 @@ var DebugRoute = function(app) {
getObjectField, getObjectField,
getObjectFields, getObjectFields,
getObjectValues, getObjectValues,
isObjectField isObjectField,
incrObjectFieldBy,
getObject
]; ];
require('async').series(tasks, function(err, results) { require('async').series(tasks, function(err, results) {

Loading…
Cancel
Save