{"action":"created","issue":{"url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver/issues/256","repository_url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver","labels_url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver/issues/256/comments","events_url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver/issues/256/events","html_url":"https://github.com/neo4j/neo4j-javascript-driver/issues/256","id":238436703,"number":256,"title":"Running transaction code (begin, commit & rollback) as a promise","user":{"login":"kmyn","id":18484353,"avatar_url":"https://avatars3.githubusercontent.com/u/18484353?v=3","gravatar_id":"","url":"https://api.github.com/users/kmyn","html_url":"https://github.com/kmyn","followers_url":"https://api.github.com/users/kmyn/followers","following_url":"https://api.github.com/users/kmyn/following{/other_user}","gists_url":"https://api.github.com/users/kmyn/gists{/gist_id}","starred_url":"https://api.github.com/users/kmyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmyn/subscriptions","organizations_url":"https://api.github.com/users/kmyn/orgs","repos_url":"https://api.github.com/users/kmyn/repos","events_url":"https://api.github.com/users/kmyn/events{/privacy}","received_events_url":"https://api.github.com/users/kmyn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-06-26T04:00:37Z","updated_at":"2017-06-27T07:40:59Z","closed_at":"2017-06-26T10:18:42Z","body":"Question: Is there a way I can run the below transaction code using promises?\r\n\r\n```javascript\r\n// run statement in a transaction\r\nvar tx = session.beginTransaction();\r\ntx.run(\"MERGE (bob:Person {name : {nameParam} }) RETURN bob.name AS name\", {nameParam: 'Bob'})\r\n  .subscribe({\r\n    onNext: function (record) {\r\n      console.log(record.get('name'));\r\n    },\r\n    onCompleted: function () {\r\n      session.close();\r\n    },\r\n    onError: function (error) {\r\n      console.log(error);\r\n    }\r\n  });\r\n\r\n//decide if the transaction should be committed or rolled back\r\nvar success = false;\r\n\r\nif (success) {\r\n  tx.commit()\r\n    .subscribe({\r\n      onCompleted: function () {\r\n        // this transaction is now committed \r\n      },\r\n      onError: function (error) {\r\n        console.log(error);\r\n      }\r\n    });\r\n} else {\r\n  //transaction is rolled black and nothing is created in the database\r\n  console.log('rolled back');\r\n  tx.rollback();\r\n}\r\n```\r\n\r\nThanks,\r\nKarthik"},"comment":{"url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver/issues/comments/311279071","html_url":"https://github.com/neo4j/neo4j-javascript-driver/issues/256#issuecomment-311279071","issue_url":"https://api.github.com/repos/neo4j/neo4j-javascript-driver/issues/256","id":311279071,"user":{"login":"lutovich","id":1638145,"avatar_url":"https://avatars1.githubusercontent.com/u/1638145?v=3","gravatar_id":"","url":"https://api.github.com/users/lutovich","html_url":"https://github.com/lutovich","followers_url":"https://api.github.com/users/lutovich/followers","following_url":"https://api.github.com/users/lutovich/following{/other_user}","gists_url":"https://api.github.com/users/lutovich/gists{/gist_id}","starred_url":"https://api.github.com/users/lutovich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lutovich/subscriptions","organizations_url":"https://api.github.com/users/lutovich/orgs","repos_url":"https://api.github.com/users/lutovich/repos","events_url":"https://api.github.com/users/lutovich/events{/privacy}","received_events_url":"https://api.github.com/users/lutovich/received_events","type":"User","site_admin":false},"created_at":"2017-06-27T07:40:59Z","updated_at":"2017-06-27T07:40:59Z","body":"@kmyn code with `Promise#all()` looks good to me. Generally it is beneficial to run queries in parallel but **I think** in your case it might create a lot of contention because of that single common node. It is hard to estimate how much parallelism one can get. The best thing I ca suggest is to measure :)"}}
{"actor":{"display_login":"lutovich"}}