Skip to content

Instantly share code, notes, and snippets.

@jessetane
Created July 3, 2012 00:16
Show Gist options
  • Save jessetane/3036561 to your computer and use it in GitHub Desktop.
Save jessetane/3036561 to your computer and use it in GitHub Desktop.
neo4j concurrency issue?
// create some nodes
var node1 = db.createNode();
var node2 = db.createNode();
// save them in parallel (works fine)
async.parallel([
function (cb) { node1.save(cb) },
function (cb) { node2.save(cb) }
], function (err) {
if (err) {
console.log(err);
} else {
// if both finish saving, try to
// simultaneously create relationships
// between the two nodes, one in each direction
async.parallel([
function (cb) { node1.createRelationshipTo(node2, 'KNOWS', {}, cb) },
function (cb) { node2.createRelationshipTo(node1, 'KNOWS', {}, cb) }
], function (err) {
if (err) {
// this is where it goes bad
console.log("no worky", err);
} else {
console.log("it worked");
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment