deleteObjectField, isObjectField in mongo

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

@ -116,7 +116,7 @@
var _fields = {};
for(var i=0; i<fields.length; ++i) {
_fields[fields[i]] = 'baris';
_fields[fields[i]] = 1;
}
db.collection('objects').findOne({_key:key}, {fields:_fields}, function(err, item) {
@ -154,11 +154,18 @@
}
module.isObjectField = function(key, field, callback) {
throw new Error('not-implemented');
module.getObjectField(key, field, function(err, item) {
callback(err, item !== undefined);
});
}
module.deleteObjectField = function(key, field, callback) {
throw new Error('not-implemented');
var data = {};
data[field] = "";
db.collection('objects').update({_key:key}, {$unset : data}, function(err, result) {
console.log(err, result);
callback(err, result);
});
}
module.incrObjectField = function(key, field, callback) {

@ -127,14 +127,33 @@ var DebugRoute = function(app) {
});
}
function isObjectField(callback) {
db.isObjectField(objectKey, 'age', function(err, data) {
console.log('isObjectField return', data);
callback(err, {'isObjectField':data});
});
}
function deleteObjectField(callback) {
db.deleteObjectField(objectKey, 'reputation', function(err, data) {
console.log('deleteObjectField return', data);
callback(err, {'deleteObjectField':data});
});
}
var tasks = [
setObject,
getObject,
deleteObjectField,
getObject,
setObjectField,
getObject,
deleteObjectField,
getObject,
getObjectField,
getObjectFields,
getObjectValues,
isObjectField
];
require('async').series(tasks, function(err, results) {

Loading…
Cancel
Save