Skip to content

Commit 7bdbc78

Browse files
committed
Fix query syntax in example and README.
1 parent b4ee8f5 commit 7bdbc78

File tree

2 files changed

+50
-32
lines changed

2 files changed

+50
-32
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var neo4j = require('build/node/neo4j');
99
var statement = ['MERGE (alice:Person {name:{name_a},age:{age_a}})',
1010
'MERGE (bob:Person {name:{name_b},age:{age_b}})',
1111
'CREATE UNIQUE (alice)-[alice_knows_bob:KNOWS]->(bob)',
12-
'RETURN alice AS, bob, alice_knows_bob'
12+
'RETURN alice, bob, alice_knows_bob'
1313
];
1414

1515
var params = {
@@ -43,17 +43,17 @@ session.run(statement.join(' '), params).subscribe({
4343
// or
4444
// the collect way, with Javascript promises:
4545
session.run(statement.join(' '), params)
46-
.then(function(records){
47-
records.forEach(function(record) {
48-
for(var i in record) {
49-
console.log(i);
50-
console.log(record[i]);
51-
}
46+
.then(function(records){
47+
records.forEach(function(record) {
48+
for(var i in record) {
49+
console.log(i);
50+
console.log(record[i]);
51+
}
52+
})
5253
})
53-
})
54-
.catch(function(error) {
55-
console.log(error);
56-
});
54+
.catch(function(error) {
55+
console.log(error);
56+
});
5757
```
5858

5959
## Building

examples/node.js

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,51 @@
22
var neo4j = require('../build/node/neo4j');
33

44
var statement = ['MERGE (alice:Person {name:{name_a},age:{age_a}})',
5-
'MERGE (bob:Person {name:{name_b},age:{age_b}})',
6-
'CREATE UNIQUE (alice)-[alice_knows_bob:KNOWS]->(bob)',
7-
'RETURN alice AS, bob, alice_knows_bob'
5+
'MERGE (bob:Person {name:{name_b},age:{age_b}})',
6+
'CREATE UNIQUE (alice)-[alice_knows_bob:KNOWS]->(bob)',
7+
'RETURN alice, bob, alice_knows_bob'
88
];
99

1010
var params = {
11-
name_a: 'Alice',
12-
age_a: 33,
13-
name_b: 'Bob',
14-
age_b: 44
11+
name_a: 'Alice',
12+
age_a: 33,
13+
name_b: 'Bob',
14+
age_b: 44
1515
};
1616

1717
var driver = neo4j.driver("neo4j://localhost");
18-
var session = driver.session();
1918

20-
session.run(statement.join(' '), params).subscribe({
21-
onNext: function(record) {
22-
// On receipt of RECORD
23-
for(var i in record) {
24-
console.log(i);
25-
console.log(record[i]);
26-
}
27-
}, onCompleted: function(metadata) {
28-
// On receipt of header summary message
29-
console.log('');
30-
console.log(metadata);
31-
}, onError: function(error) {
32-
console.log(error);
19+
var streamSession = driver.session();
20+
streamSession.run(statement.join(' '), params).subscribe({
21+
onNext: function(record) {
22+
// On receipt of RECORD
23+
for(var i in record) {
24+
console.log(i);
25+
console.log(record[i]);
3326
}
27+
}, onCompleted: function(metadata) {
28+
// On receipt of header summary message
29+
console.log('');
30+
console.log(metadata);
31+
streamSession.close();
32+
}, onError: function(error) {
33+
console.log(error);
34+
}
3435
});
36+
37+
var promiseSession = driver.session();
38+
promiseSession.run(statement.join(' '), params)
39+
.then(function(records){
40+
records.forEach(function(record) {
41+
for(var i in record) {
42+
console.log(i);
43+
console.log(record[i]);
44+
}
45+
})
46+
})
47+
.catch(function(error) {
48+
console.log(error);
49+
})
50+
.then(function(){
51+
promiseSession.close();
52+
});

0 commit comments

Comments
 (0)