Created
July 3, 2012 00:16
-
-
Save jessetane/3036561 to your computer and use it in GitHub Desktop.
neo4j concurrency issue?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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