File tree Expand file tree Collapse file tree 12 files changed +373
-435
lines changed
Expand file tree Collapse file tree 12 files changed +373
-435
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "presets" : [" es2015" , " stage-3" ],
3+ "plugins" : []
4+ }
Original file line number Diff line number Diff line change 11/.settings /
22/node_modules /
33.project
4- package-lock.json
4+ package-lock.json
5+ yarn.lock
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- const RedisGraph = require ( ' ../src/redisGraph' ) ;
1+ const RedisGraph = require ( " ../src/redisGraph" ) ;
22
3-
4- let graph = new RedisGraph ( 'social' ) ;
3+ let graph = new RedisGraph ( "social" ) ;
54
65graph
7- . query ( "CREATE (:person{name:'roi',age:32})" )
8- . then ( ( ) => {
9- return graph . query ( "CREATE (:person{name:'amit',age:30})" ) ;
10- } )
11- . then ( ( ) => {
12- return graph . query ( "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(a)" ) ;
13- } )
14- . then ( ( ) => {
15- return graph . query ( "MATCH (a:person)-[:knows]->(:person) RETURN a" ) ;
16- } )
17- . then ( ( res ) => {
18- while ( res . hasNext ( ) ) {
19- let record = res . next ( ) ;
20- console . log ( record . getString ( 'a.name' ) ) ;
21- }
22- console . log ( res . getStatistics ( ) . queryExecutionTime ( ) ) ;
23- } )
24- . catch ( ( err ) => {
25- console . log ( err ) ;
26- } ) ;
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+ } ) ;
Original file line number Diff line number Diff line change 11{
2- "name" : " redisgraph.js" ,
3- "version" : " 1.0.2" ,
4- "description" : " Connect to RedisGraph 1.0.0 and up from JavaScript" ,
5- "author" : " RedisLabs" ,
6- "license" : " BSD 3" ,
7- "repository" : {
8- "type" : " git" ,
9- "url" : " git://github.com/redislabs/redisgraph.js.git"
10- },
11- "dependencies" : {
12- "redis" : " ^2.8.0"
13- },
14- "devDependencies" : {
15- "mocha" : " ^5.2.0"
16- },
17- "scripts" : {
18- "test" : " mocha"
19- }
2+ "name" : " redisgraph.js" ,
3+ "version" : " 1.0.2" ,
4+ "description" : " Connect to RedisGraph 1.0.0 and up from JavaScript" ,
5+ "author" : " RedisLabs" ,
6+ "license" : " BSD 3" ,
7+ "repository" : {
8+ "type" : " git" ,
9+ "url" : " git://github.com/redislabs/redisgraph.js.git"
10+ },
11+ "dependencies" : {
12+ "redis" : " ^2.8.0"
13+ },
14+ "devDependencies" : {
15+ "babel-core" : " ^6.26.3" ,
16+ "babel-preset-latest" : " ^6.24.1" ,
17+ "babel-preset-stage-3" : " ^6.24.1" ,
18+ "mocha" : " ^5.2.0"
19+ },
20+ "scripts" : {
21+ "test" : " mocha -R spec --require babel-core/register --exit"
22+ },
23+ "main" : " ./src/index.js"
2024}
Original file line number Diff line number Diff line change 1+ import Record from "./record" ;
2+ import RedisGraph from "./redisGraph" ;
3+ import ResultSet from "./resultSet" ;
4+ import Statistics from "./statistics" ;
5+ import Label from "./label" ;
6+
7+ const redisGraph = {
8+ Record : Record ,
9+ RedisGraph : RedisGraph ,
10+ ResultSet : ResultSet ,
11+ Statistics : Statistics ,
12+ Label : Label
13+ } ;
14+
15+ export default redisGraph ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Different Statistics labels
3+ */
4+ const Label = Object . freeze ( {
5+ LABELS_ADDED : "Labels added" ,
6+ NODES_CREATED : "Nodes created" ,
7+ NODES_DELETED : "Nodes deleted" ,
8+ RELATIONSHIPS_DELETED : "Relationships deleted" ,
9+ PROPERTIES_SET : "Properties set" ,
10+ RELATIONSHIPS_CREATED : "Relationships created" ,
11+ QUERY_INTERNAL_EXECUTION_TIME : "Query internal execution time"
12+ } ) ;
13+
14+ export default Label ;
Original file line number Diff line number Diff line change 11/**
22 * Hold a query record
33 */
4- module . exports = class Record {
5-
6- constructor ( header , values ) {
7- this . _header = header ;
8- this . _values = values ;
4+ class Record {
5+ constructor ( header , values ) {
6+ this . _header = header ;
7+ this . _values = values ;
8+ }
9+
10+ getString ( key ) {
11+ let index = key ;
12+ if ( typeof key === "string" ) {
13+ index = this . _header . indexOf ( key ) ;
914 }
10-
11- getString ( key ) {
12- let index = key ;
13- if ( typeof key === "string" ) {
14- index = this . _header . indexOf ( key ) ;
15- }
16- return this . _values [ index ] ;
17- }
15+ return this . _values [ index ] ;
16+ }
17+
18+ keys ( ) {
19+ return this . _header ;
20+ }
1821
19- keys ( ) {
20- return this . _header ;
21- }
22+ values ( ) {
23+ return this . _values ;
24+ }
2225
23- values ( ) {
24- return this . _values ;
25- }
26+ containsKey ( key ) {
27+ return this . _header . includes ( key ) ;
28+ }
2629
27- containsKey ( key ) {
28- return this . _header . includes ( key ) ;
29- }
30+ size ( ) {
31+ return this . _header . length ;
32+ }
33+ }
3034
31- size ( ) {
32- return this . _header . length ;
33- }
34- }
35+ export default Record ;
You can’t perform that action at this time.
0 commit comments