From 7003a3e8c74d334968e9a3638101a067ceca1398 Mon Sep 17 00:00:00 2001 From: Mike P Date: Sat, 18 Aug 2012 11:22:00 -0300 Subject: [PATCH 1/5] Update lib/abstract-class.js make sure that callback is called when there are no records or data in the all method --- lib/abstract-class.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/abstract-class.js b/lib/abstract-class.js index aa958c5b..ab33b431 100644 --- a/lib/abstract-class.js +++ b/lib/abstract-class.js @@ -355,6 +355,8 @@ AbstractClass.all = function all(params, cb) { } cb(err, collection); } + else + cb(err, []); }); }; From 53831da913c77f4d845544cdbf1841054569b02b Mon Sep 17 00:00:00 2001 From: Mike P Date: Sat, 18 Aug 2012 11:24:12 -0300 Subject: [PATCH 2/5] Update lib/adapters/neo4j.js don't save an id property on update since there is already a node id from neo4j --- lib/adapters/neo4j.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/adapters/neo4j.js b/lib/adapters/neo4j.js index 02cd858f..e832d8f8 100644 --- a/lib/adapters/neo4j.js +++ b/lib/adapters/neo4j.js @@ -342,6 +342,9 @@ Neo4j.prototype.updateAttributes = function updateAttributes(model, id, data, cb function cleanup(data) { if (!data) return null; + + //don't save an id property on update since there is already a node id from neo4j + delete data.id; var res = {}; Object.keys(data).forEach(function (key) { var v = data[key]; From df798791fa44d7a70b2980602c960b4033610536 Mon Sep 17 00:00:00 2001 From: Mike P Date: Sat, 18 Aug 2012 11:47:15 -0300 Subject: [PATCH 3/5] Update lib/adapters/neo4j.js removing the change to delete the id property in the cleanup since that fails the unit test --- lib/adapters/neo4j.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/adapters/neo4j.js b/lib/adapters/neo4j.js index e832d8f8..b75c718a 100644 --- a/lib/adapters/neo4j.js +++ b/lib/adapters/neo4j.js @@ -343,8 +343,6 @@ Neo4j.prototype.updateAttributes = function updateAttributes(model, id, data, cb function cleanup(data) { if (!data) return null; - //don't save an id property on update since there is already a node id from neo4j - delete data.id; var res = {}; Object.keys(data).forEach(function (key) { var v = data[key]; From 3ca47526e5cf49365a4ca8c1b6c7cb1a66d44ceb Mon Sep 17 00:00:00 2001 From: Mike P Date: Sat, 18 Aug 2012 12:40:58 -0300 Subject: [PATCH 4/5] =?UTF-8?q?re-adding=20fix=C2=A0to=20not=20save=20id?= =?UTF-8?q?=20as=20a=20property=20on=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/adapters/neo4j.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/adapters/neo4j.js b/lib/adapters/neo4j.js index b75c718a..f8202964 100644 --- a/lib/adapters/neo4j.js +++ b/lib/adapters/neo4j.js @@ -200,6 +200,8 @@ Neo4j.prototype.updateIndexes = function updateIndexes(model, node, cb) { Neo4j.prototype.save = function save(model, data, callback) { 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) { if (err) return callback(err); node.data = cleanup(data); @@ -207,6 +209,8 @@ Neo4j.prototype.save = function save(model, data, callback) { 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); }); }); From 94fb10d5605ccd980292f11dcb754165da732bcd Mon Sep 17 00:00:00 2001 From: Mike P Date: Sat, 18 Aug 2012 12:42:43 -0300 Subject: [PATCH 5/5] I put the delete in the wrong line, moved down.. --- lib/adapters/neo4j.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/adapters/neo4j.js b/lib/adapters/neo4j.js index f8202964..cf5c3f99 100644 --- a/lib/adapters/neo4j.js +++ b/lib/adapters/neo4j.js @@ -200,9 +200,10 @@ Neo4j.prototype.updateIndexes = function updateIndexes(model, node, cb) { Neo4j.prototype.save = function save(model, data, callback) { 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) { + //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) {