Skip to content

Commit c295f3f

Browse files
committed
fix readme.md, example, null value to string. closes #20, closes #18. might close #19
1 parent 17725ca commit c295f3f

File tree

4 files changed

+267
-234
lines changed

4 files changed

+267
-234
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ graph
3636
return graph.query("CREATE (:person{name:'amit',age:30})");
3737
})
3838
.then( () => {
39-
return graph.query("MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(a)")
39+
return graph.query("MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)")
4040
})
4141
.then( () => {
4242
return graph.query("MATCH (a:person)-[:knows]->(:person) RETURN a")

examples/redisGraphExample.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ const RedisGraph = require("redisgraph.js").RedisGraph;
33
let graph = new RedisGraph("social");
44

55
graph
6-
.query("CREATE (:person{name:'roi',age:32})")
7-
.then(() => {
8-
return graph.query("CREATE (:person{name:'amit',age:30})");
9-
})
10-
.then(() => {
11-
return graph.query(
12-
"MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(a)"
13-
);
14-
})
15-
.then(() => {
16-
return graph.query("MATCH (a:person)-[:knows]->(:person) RETURN a");
17-
})
18-
.then(res => {
19-
while (res.hasNext()) {
20-
let record = res.next();
21-
console.log(record.getString("a.name"));
22-
}
23-
console.log(res.getStatistics().queryExecutionTime());
24-
})
25-
.catch(err => {
26-
console.log(err);
27-
});
6+
.query("CREATE (:person{name:'roi',age:32})")
7+
.then(() => {
8+
return graph.query("CREATE (:person{name:'amit',age:30})");
9+
})
10+
.then(() => {
11+
return graph.query(
12+
"MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)"
13+
);
14+
})
15+
.then(() => {
16+
return graph.query("MATCH (a:person)-[:knows]->(:person) RETURN a");
17+
})
18+
.then(res => {
19+
while (res.hasNext()) {
20+
let record = res.next();
21+
console.log(record.getString("a.name"));
22+
}
23+
console.log(res.getStatistics().queryExecutionTime());
24+
})
25+
.catch(err => {
26+
console.log(err);
27+
});

src/record.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@
22
* Hold a query record
33
*/
44
class Record {
5-
constructor(header, values) {
6-
this._header = header;
7-
this._values = values;
8-
}
5+
constructor(header, values) {
6+
this._header = header;
7+
this._values = values;
8+
}
99

10-
get(key) {
11-
let index = key;
12-
if (typeof key === "string") {
13-
index = this._header.indexOf(key);
14-
}
15-
return this._values[index];
16-
}
17-
18-
getString(key) {
19-
let index = key;
20-
if (typeof key === "string") {
21-
index = this._header.indexOf(key);
22-
}
23-
return this._values[index].toString();
24-
}
10+
get(key) {
11+
let index = key;
12+
if (typeof key === "string") {
13+
index = this._header.indexOf(key);
14+
}
15+
return this._values[index];
16+
}
2517

26-
keys() {
27-
return this._header;
28-
}
18+
getString(key) {
19+
let index = key;
20+
if (typeof key === "string") {
21+
index = this._header.indexOf(key);
22+
}
23+
return this._values[index] ? this._values[index].toString() : null;
24+
}
2925

30-
values() {
31-
return this._values;
32-
}
26+
keys() {
27+
return this._header;
28+
}
3329

34-
containsKey(key) {
35-
return this._header.includes(key);
36-
}
30+
values() {
31+
return this._values;
32+
}
3733

38-
size() {
39-
return this._header.length;
40-
}
34+
containsKey(key) {
35+
return this._header.includes(key);
36+
}
37+
38+
size() {
39+
return this._header.length;
40+
}
4141
}
4242

4343
module.exports = Record;

0 commit comments

Comments
 (0)