|
16 | 16 | * See the License for the specific language governing permissions and
|
17 | 17 | * limitations under the License.
|
18 | 18 | */
|
19 |
| - |
20 |
| -var neo4j = require('neo4j'); |
| 19 | + |
| 20 | +var neo4j = require('neo4j') |
21 | 21 |
|
22 | 22 | var statement = ['MERGE (alice:Person {name:{name_a},age:{age_a}})',
|
23 | 23 | 'MERGE (bob:Person {name:{name_b},age:{age_b}})',
|
24 | 24 | 'CREATE UNIQUE (alice)-[alice_knows_bob:KNOWS]->(bob)',
|
25 | 25 | 'RETURN alice, bob, alice_knows_bob'
|
26 |
| -]; |
| 26 | +] |
27 | 27 |
|
28 | 28 | var params = {
|
29 | 29 | name_a: 'Alice',
|
30 | 30 | age_a: 33,
|
31 | 31 | name_b: 'Bob',
|
32 | 32 | age_b: 44
|
33 |
| -}; |
| 33 | +} |
34 | 34 |
|
35 |
| -var driver = neo4j.driver("bolt://localhost"); |
| 35 | +var driver = neo4j.driver('bolt://localhost') |
36 | 36 |
|
37 |
| -var streamSession = driver.session(); |
38 |
| -var streamResult = streamSession.run(statement.join(' '), params); |
| 37 | +var streamSession = driver.session() |
| 38 | +var streamResult = streamSession.run(statement.join(' '), params) |
39 | 39 | streamResult.subscribe({
|
40 |
| - onNext: function(record) { |
| 40 | + onNext: function (record) { |
41 | 41 | // On receipt of RECORD
|
42 |
| - for(var i in record) { |
43 |
| - console.log(i); |
44 |
| - console.log(record[i]); |
| 42 | + for (var i in record) { |
| 43 | + console.log(i) |
| 44 | + console.log(record[i]) |
45 | 45 | }
|
46 |
| - }, onCompleted: function() { |
47 |
| - var summary = streamResult.summarize(); |
48 |
| - //Print number of nodes created |
49 |
| - console.log(''); |
50 |
| - console.log(summary.updateStatistics.nodesCreated()); |
51 |
| - streamSession.close(); |
52 |
| - }, onError: function(error) { |
53 |
| - console.log(error); |
| 46 | + }, |
| 47 | + onCompleted: function () { |
| 48 | + var summary = streamResult.summarize() |
| 49 | + // Print number of nodes created |
| 50 | + console.log('') |
| 51 | + console.log(summary.updateStatistics.nodesCreated()) |
| 52 | + streamSession.close() |
| 53 | + }, |
| 54 | + onError: function (error) { |
| 55 | + console.log(error) |
54 | 56 | }
|
55 |
| -}); |
| 57 | +}) |
56 | 58 |
|
57 |
| -var promiseSession = driver.session(); |
58 |
| -var promiseResult = promiseSession.run(statement.join(' '), params); |
59 |
| -promiseResult.then(function(records) { |
60 |
| - records.forEach(function(record) { |
61 |
| - for(var i in record) { |
62 |
| - console.log(i); |
63 |
| - console.log(record[i]); |
| 59 | +var promiseSession = driver.session() |
| 60 | +var promiseResult = promiseSession.run(statement.join(' '), params) |
| 61 | +promiseResult.then(function (records) { |
| 62 | + records.forEach(function (record) { |
| 63 | + for (var i in record) { |
| 64 | + console.log(i) |
| 65 | + console.log(record[i]) |
64 | 66 | }
|
65 |
| - }); |
66 |
| - var summary = promiseResult.summarize(); |
67 |
| - //Print number of nodes created |
68 |
| - console.log(''); |
69 |
| - console.log(summary.updateStatistics.nodesCreated()); |
70 |
| -}) |
71 |
| -.catch(function(error) { |
72 |
| - console.log(error); |
| 67 | + }) |
| 68 | + var summary = promiseResult.summarize() |
| 69 | + // Print number of nodes created |
| 70 | + console.log('') |
| 71 | + console.log(summary.updateStatistics.nodesCreated()) |
73 | 72 | })
|
74 |
| -.then(function(){ |
75 |
| - promiseSession.close(); |
76 |
| -}); |
| 73 | + .catch(function (error) { |
| 74 | + console.log(error) |
| 75 | + }) |
| 76 | + .then(function () { |
| 77 | + promiseSession.close() |
| 78 | + }) |
0 commit comments