File tree Expand file tree Collapse file tree 1 file changed +40
-40
lines changed Expand file tree Collapse file tree 1 file changed +40
-40
lines changed Original file line number Diff line number Diff line change @@ -22,49 +22,49 @@ $ go get github.com/redislabs/redisgraph-go
2222package main
2323
2424import (
25- " github.com/gomodule/redigo/redis"
26- rg " github.com/redislabs/redisgraph-go"
25+ " github.com/gomodule/redigo/redis"
26+ rg " github.com/redislabs/redisgraph-go"
2727)
2828
2929func main () {
30- conn , _ := redis.Dial (" tcp" , " 0.0.0.0:6379" )
31- defer conn.Close ()
32-
33- graph := rg.Graph {}. New (" social" , conn)
34-
35- john := rg.Node {
36- Label: " person" ,
37- Properties: map [string ]interface {}{
38- " name" : " John Doe" ,
39- " age" : 33 ,
40- " gender" : " male" ,
41- " status" : " single" ,
42- },
43- }
44- graph.AddNode (&john)
45-
46- japan := rg.Node {
47- Label: " country" ,
48- Properties: map [string ]interface {}{
49- " name" : " Japan" ,
50- },
51- }
52- graph.AddNode (&japan)
53-
54- edge := rg.Edge {
55- Source: &john,
56- Relation: " visited" ,
57- Destination: &japan,
58- }
59- graph.AddEdge (&edge)
60-
61- graph.Commit ()
62-
63- query := ` MATCH (p:person)-[v:visited]->(c:country)
64- RETURN p.name, p.age, v.purpose, c.name`
65- rs , _ := graph.Query (query)
66-
67- rs.PrettyPrint ()
30+ conn , _ := redis.Dial (" tcp" , " 0.0.0.0:6379" )
31+ defer conn.Close ()
32+
33+ graph := rg.GraphNew (" social" , conn)
34+
35+ john := rg.Node {
36+ Label: " person" ,
37+ Properties: map [string ]interface {}{
38+ " name" : " John Doe" ,
39+ " age" : 33 ,
40+ " gender" : " male" ,
41+ " status" : " single" ,
42+ },
43+ }
44+ graph.AddNode (&john)
45+
46+ japan := rg.Node {
47+ Label: " country" ,
48+ Properties: map [string ]interface {}{
49+ " name" : " Japan" ,
50+ },
51+ }
52+ graph.AddNode (&japan)
53+
54+ edge := rg.Edge {
55+ Source: &john,
56+ Relation: " visited" ,
57+ Destination: &japan,
58+ }
59+ graph.AddEdge (&edge)
60+
61+ graph.Commit ()
62+
63+ query := ` MATCH (p:person)-[v:visited]->(c:country)
64+ RETURN p.name, p.age, v.purpose, c.name`
65+ rs , _ := graph.Query (query)
66+
67+ rs.PrettyPrint ()
6868}
6969```
7070
You can’t perform that action at this time.
0 commit comments