Skip to content

Commit 96c96d7

Browse files
committed
Adds README and LICENSE
Signed-off-by: Itamar Haber <[email protected]>
1 parent 297b468 commit 96c96d7

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, Redis Labs
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+85-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,87 @@
11
# redisgraph-go
22

3-
A Golang client for redisgraph
3+
`redisgraph-go` is a Golang client for the [RedisGraph](https://oss.redislabs.com/redisgraph/) module. It relies on [`redigo`](https://github.com/gomodule/redigo) for Redis connection management and provides support for RedisGraph's QUERY, EXPLAIN, and DELETE commands.
4+
5+
## Installation
6+
7+
Simply do:
8+
```sh
9+
$ go get github.com/redislabs/redisgraph-go
10+
```
11+
12+
## Usage
13+
14+
```go
15+
package main
16+
17+
import (
18+
"github.com/gomodule/redigo/redis"
19+
"github.com/redislabs/redisgraph-go"
20+
)
21+
22+
func main() {
23+
conn, _ := redis.Dial("tcp", "0.0.0.0:6379")
24+
defer conn.Close()
25+
26+
rg := Graph{}.New("social", conn)
27+
28+
john := Node{
29+
Label: "person",
30+
Properties: map[string]interface{}{
31+
"name": "John Doe",
32+
"age": 33,
33+
"gender": "male",
34+
"status": "single",
35+
},
36+
}
37+
rg.AddNode(&john)
38+
39+
japan := Node{
40+
Label: "country",
41+
Properties: map[string]interface{}{
42+
"name": "Japan",
43+
},
44+
}
45+
rg.AddNode(&japan)
46+
47+
edge := Edge{
48+
Source: &john,
49+
Relation: "visited",
50+
Destination: &japan,
51+
}
52+
rg.AddEdge(&edge)
53+
54+
rg.Commit()
55+
56+
query := `MATCH (p:person)-[v:visited]->(c:country)
57+
RETURN p.name, p.age, v.purpose, c.name`
58+
rs, _ := rg.Query(query)
59+
60+
rs.PrettyPrint()
61+
}
62+
```
63+
64+
Running the above should output:
65+
66+
```sh
67+
$ go run main.go
68+
+----------+-----------+-----------+--------+
69+
| p.name | p.age | v.purpose | c.name |
70+
+----------+-----------+-----------+--------+
71+
| John Doe | 33.000000 | NULL | Japan |
72+
+----------+-----------+-----------+--------+
73+
```
74+
75+
## Running tests
76+
77+
A simple test suite is provided, and can be run with:
78+
79+
```sh
80+
$ go test
81+
```
82+
83+
The tests expect a Redis server with the RedisGraph module loaded to be available at localhost:6379
84+
85+
## License
86+
87+
redisgraph-go is distributed under the BSD3 license - see [LICENSE](LICENSE)

0 commit comments

Comments
 (0)