@@ -22,6 +22,12 @@ Installation is done using the
2222npm install redisgraph.js
2323```
2424
25+ For installing the latest snapshot use
26+ ``` bash
27+ npm install github:RedisGraph/redisgraph.js.git
28+ ```
29+
30+
2531## Overview
2632
2733### Official Releases
@@ -34,39 +40,38 @@ const RedisGraph = require("redisgraph.js").Graph;
3440
3541let graph = new RedisGraph (" social" );
3642
37- graph .query (" CREATE (:person{name:'roi',age:32})" ).then (() => {
38- graph .query (" CREATE (:person{name:'amit',age:30})" ).then (()=> {
39- graph .query (" MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)" ).then (()=> {
40- graph .query (" MATCH (a:person)-[:knows]->(:person) RETURN a.name" ).then (res => {
41- while (res .hasNext ()) {
42- let record = res .next ();
43- console .log (record .get (" a.name" ));
44- }
45- console .log (res .getStatistics ().queryExecutionTime ());
46- let param = {' age' : 30 };
47- graph .query (" MATCH (a {age: $age}) return a.name" , param).then (res => {
48- while (res .hasNext ()) {
49- let record = res .next ();
50- console .log (record .get (" a.name" ));
51- }
52- graph .query (" MATCH p = (a:person)-[:knows]->(:person) RETURN p" ).then (res => {
53- while (res .hasNext ()) {
54- let record = res .next ();
55- // See path.js for more path API.
56- console .log (record .get (" p" ).nodeCount );
57- graph .deleteGraph ();
58- process .exit ();
59- }
60- })
61- })
62- })
63- })
64- })
65- })
66- .catch (err => {
67- console .log (err);
68- });
69-
43+ (async () => {
44+ await graph .query (" CREATE (:person{name:'roi',age:32})" );
45+ await graph .query (" CREATE (:person{name:'amit',age:30})" );
46+ await graph .query (" MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(b)" );
47+
48+ // Match query.
49+ let res = await graph .query (" MATCH (a:person)-[:knows]->(:person) RETURN a.name" );
50+ while (res .hasNext ()) {
51+ let record = res .next ();
52+ console .log (record .get (" a.name" ));
53+ }
54+ console .log (res .getStatistics ().queryExecutionTime ());
55+
56+ // Match with parameters.
57+ let param = {' age' : 30 };
58+ res = await graph .query (" MATCH (a {age: $age}) return a.name" , param);
59+ while (res .hasNext ()) {
60+ let record = res .next ();
61+ console .log (record .get (" a.name" ));
62+ }
63+
64+ // Named paths matching.
65+ res = await graph .query (" MATCH p = (a:person)-[:knows]->(:person) RETURN p" );
66+ while (res .hasNext ()) {
67+ let record = res .next ();
68+ // See path.js for more path API.
69+ console .log (record .get (" p" ).nodeCount );
70+ graph .deleteGraph ();
71+ process .exit ();
72+ }
73+
74+ })();
7075
7176```
7277
0 commit comments