Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-28-2020 11:01 AM
I'm calling a procedure 80 times to perform queries with args, but only the first create is executed, when I look in the neo4j browser. Here is the code of the procedure:
var savedBookmarks = []
function op_modifyQuery(txc,query,args){
return new Promise(function(resolve,reject){
var session = driver.session({
defaultAccessMode: neo4j.WRITE,
bookmarks: savedBookmarks
});
session.writeTransaction(function(tx) {
tx.run(query,args).then(function(result) {
var bm = session.lastBookmark();
savedBookmarks.push(bm)
console.log('OK=',savedBookmarks.length,'=',JSON.stringify(bm),query);
resolve(result);
}).catch(function(error) {
console.error('Query failed!', error);
reject(error2msg('IMP999',error));
}).finally(function() {
session.close();
}).catch(function(error) {
console.error('Session failed!', error);
reject(error2msg('IMP998',error));
});
});
});
}
The result output (truncated to 4 lines out of 80)
OK= 1 = [] CREATE (t:qSurvey {uuid:$topKeyParam,name:$nameParam} ) RETURN 'qSurvey' AS node,t.uuid,t.name
OK= 2 = [] MATCH (t:qSurvey {uuid:$topKeyParam} ) CREATE (p:qPage {uuid:$pageKeyParam,name:$nameParam}) CREATE (t)-[r:hasPage]->(p) RETURN 'gPage' AS node,p.uuid,p.name
OK= 3 = [] MATCH (p:qPage) WHERE p.uuid = $pageKeyParam CREATE (e:qElement {uuid:$elementKeyParam,type:$typeParam,name:$nameParam,title:$titleParam,isRequired:$reqParam} ) CREATE (p)-[r:hasElement]->(e) RETURN 'qElement' AS node,e.uuid,e.type,e.name,e.title,e.isRequiered
OK= 4 = [] MATCH (e:qElement) WHERE e.uuid = $elementKeyParam CREATE (c:qChoice {uuid:$choiceKeyParam,value:$valueParam,text:$textParam} ) CREATE (e)-[r:hasChoice]->(c) RETURN 'qChoice' AS node,c.uuid,c.value,c.text
I assume, that the driver can only handle the first create, even if the arguments are all correct.
This code is my fifth rewrite doing separate sessions per query, before, I tried to use beginTransaction, but there I got error messages like "cannot commit a session in ready state".
Thank you for any help..
Oliver Weimar-Drese
All the sessions of the conference are now available online