Merge pull request #111 from mypark/master
fixes to make sure callback was called on the all method and to get neo4j adapter working with railway
This commit is contained in:
commit
60fad51623
|
@ -355,6 +355,8 @@ AbstractClass.all = function all(params, cb) {
|
|||
}
|
||||
cb(err, collection);
|
||||
}
|
||||
else
|
||||
cb(err, []);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue