File tree Expand file tree Collapse file tree 3 files changed +284
-243
lines changed Expand file tree Collapse file tree 3 files changed +284
-243
lines changed Original file line number Diff line number Diff line change @@ -3,25 +3,25 @@ const RedisGraph = require("redisgraph.js").RedisGraph;
3
3
let graph = new RedisGraph ( "social" ) ;
4
4
5
5
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
+ } ) ;
Original file line number Diff line number Diff line change 2
2
* Hold a query record
3
3
*/
4
4
class Record {
5
- constructor ( header , values ) {
6
- this . _header = header ;
7
- this . _values = values ;
8
- }
9
-
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
-
24
- if ( this . _values [ index ] ) {
25
- return this . _values [ index ] . toString ( ) ;
26
- }
27
-
28
- return null ;
29
- }
30
-
31
- keys ( ) {
32
- return this . _header ;
33
- }
34
-
35
- values ( ) {
36
- return this . _values ;
37
- }
38
-
39
- containsKey ( key ) {
40
- return this . _header . includes ( key ) ;
41
- }
42
-
43
- size ( ) {
44
- return this . _header . length ;
45
- }
5
+ constructor ( header , values ) {
6
+ this . _header = header ;
7
+ this . _values = values ;
8
+ }
9
+
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
+
24
+ if ( this . _values [ index ] ) {
25
+ return this . _values [ index ] . toString ( ) ;
26
+ }
27
+
28
+ return null ;
29
+ }
30
+
31
+ getString ( key ) {
32
+ let index = key ;
33
+ if ( typeof key === "string" ) {
34
+ index = this . _header . indexOf ( key ) ;
35
+ }
36
+ return this . _values [ index ] ? this . _values [ index ] . toString ( ) : null ;
37
+ }
38
+
39
+ keys ( ) {
40
+ return this . _header ;
41
+ }
42
+
43
+ values ( ) {
44
+ return this . _values ;
45
+ }
46
+
47
+ containsKey ( key ) {
48
+ return this . _header . includes ( key ) ;
49
+ }
50
+
51
+ size ( ) {
52
+ return this . _header . length ;
53
+ }
46
54
}
47
55
48
56
module . exports = Record ;
You can’t perform that action at this time.
0 commit comments