re-adding fix to not save id as a property on update

This commit is contained in:
Mike P 2012-08-18 12:40:58 -03:00
parent df798791fa
commit 3ca47526e5
1 changed files with 4 additions and 0 deletions

View File

@ -200,6 +200,8 @@ Neo4j.prototype.updateIndexes = function updateIndexes(model, node, cb) {
Neo4j.prototype.save = function save(model, data, callback) { Neo4j.prototype.save = function save(model, data, callback) {
var self = this; var self = this;
//delete id property since that's redundant and we use the node.id
delete data.id;
this.node(data.id, function (err, node) { this.node(data.id, function (err, node) {
if (err) return callback(err); if (err) return callback(err);
node.data = cleanup(data); node.data = cleanup(data);
@ -207,6 +209,8 @@ Neo4j.prototype.save = function save(model, data, callback) {
if (err) return callback(err); if (err) return callback(err);
self.updateIndexes(model, node, function (err) { self.updateIndexes(model, node, function (err) {
if (err) return console.log(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); callback(null, node.data);
}); });
}); });