File tree Expand file tree Collapse file tree 4 files changed +267
-234
lines changed Expand file tree Collapse file tree 4 files changed +267
-234
lines changed Original file line number Diff line number Diff line change 36
36
return graph .query (" CREATE (:person{name:'amit',age:30})" );
37
37
})
38
38
.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 )" )
40
40
})
41
41
.then ( () => {
42
42
return graph .query (" MATCH (a:person)-[:knows]->(:person) RETURN a" )
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
- }
5
+ constructor ( header , values ) {
6
+ this . _header = header ;
7
+ this . _values = values ;
8
+ }
9
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
- 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
+ }
25
17
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
+ }
29
25
30
- values ( ) {
31
- return this . _values ;
32
- }
26
+ keys ( ) {
27
+ return this . _header ;
28
+ }
33
29
34
- containsKey ( key ) {
35
- return this . _header . includes ( key ) ;
36
- }
30
+ values ( ) {
31
+ return this . _values ;
32
+ }
37
33
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
+ }
41
41
}
42
42
43
43
module . exports = Record ;
You can’t perform that action at this time.
0 commit comments