Merge branch 'master' of github.com:1602/jugglingdb

This commit is contained in:
Anatoliy Chakkaev 2012-08-24 12:22:22 +04:00
commit a3963485f5
2 changed files with 8 additions and 0 deletions

View File

@ -356,6 +356,8 @@ AbstractClass.all = function all(params, cb) {
}
cb(err, collection);
}
else
cb(err, []);
});
};

View File

@ -200,13 +200,18 @@ Neo4j.prototype.updateIndexes = function updateIndexes(model, node, cb) {
Neo4j.prototype.save = function save(model, data, callback) {
var self = this;
this.node(data.id, function (err, node) {
//delete id property since that's redundant and we use the node.id
delete data.id;
if (err) return callback(err);
node.data = cleanup(data);
node.save(function (err) {
if (err) return callback(err);
self.updateIndexes(model, node, function (err) {
if (err) return console.log(err);
//map node id to the id property being sent back
node.data.id = node.id;
callback(null, node.data);
});
});
@ -342,6 +347,7 @@ Neo4j.prototype.updateAttributes = function updateAttributes(model, id, data, cb
function cleanup(data) {
if (!data) return null;
var res = {};
Object.keys(data).forEach(function (key) {
var v = data[key];