• Stars
    star
    389
  • Rank 106,508 (Top 3 %)
  • Language
    Go
  • Created almost 12 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Neo4j client for Golang

neoism - Neo4j client for Go

Neoism Logo

Package neoism is a Go client library providing access to the Neo4j graph database via its REST API.

Status

System Status
Travis CI Travis CI
CircleCI CircleCI
Coveralls Coveralls
Codecov Codecov

This driver is fairly complete, and may now be suitable for general use. The code has an extensive set of integration tests, but little real-world testing. YMMV; use in production at your own risk.

Requirements

Go 1.1 or later is required.

Tested against Neo4j 2.2.4 and Go 1.4.1.

Installation

Development

go get -v github.com/jmcvetta/neoism

Stable

Neoism is versioned using gopkg.in.

Current release is v1

go get gopkg.in/jmcvetta/neoism.v1

Documentation

See GoDoc or Go Walker for automatically generated documentation.

Usage

Connect to Neo4j Database

db, err := neoism.Connect("http://localhost:7474/db/data")

Create a Node

n, err := db.CreateNode(neoism.Props{"name": "Captain Kirk"})

Issue a Cypher Query

// res will be populated with the query results.  It must be a slice of structs.
res := []struct {
		// `json:` tags matches column names in query
		A   string `json:"a.name"` 
		Rel string `json:"type(r)"`
		B   string `json:"b.name"`
	}{}

// cq holds the Cypher query itself (required), any parameters it may have 
// (optional), and a pointer to a result object (optional).
cq := neoism.CypherQuery{
	// Use backticks for long statements - Cypher is whitespace indifferent
	Statement: `
		MATCH (a:Person)-[r]->(b)
		WHERE a.name = {name}
		RETURN a.name, type(r), b.name
	`,
	Parameters: neoism.Props{"name": "Dr McCoy"},
	Result:     &res,
}

// Issue the query.
err := db.Cypher(&cq)

// Get the first result.
r := res[0]

Issue Cypher queries with a transaction

tx, err := db.Begin(qs)
if err != nil {
  // Handle error
}

cq0 := neoism.CypherQuery{
  Statement: `MATCH (a:Account) WHERE a.uuid = {account_id} SET balance = balance + {amount}`,
  Parameters: neoism.Props{"uuid": "abc123", amount: 20},
}
err = db.Cypher(&cq0)
if err != nil {
  // Handle error
}

cq1 := neoism.CypherQuery{
  Statement: `MATCH (a:Account) WHERE a.uuid = {account_id} SET balance = balance + {amount}`,
  Parameters: neoism.Props{"uuid": "def456", amount: -20},
}
err = db.Cypher(&cq1)
if err != nil {
  // Handle error
}

err := tx.Commit()
if err != nil {
  // Handle error
}

Roadmap

Completed:

  • Node (create/edit/relate/delete/properties)
  • Relationship (create/edit/delete/properties)
  • Legacy Indexing (create/edit/delete/add node/remove node/find/query)
  • Cypher queries
  • Batched Cypher queries
  • Transactional endpoint (Neo4j 2.0)
  • Node labels (Neo4j 2.0)
  • Schema index (Neo4j 2.0)
  • Authentication (Neo4j 2.2)

To Do:

  • Streaming API support - see Issue #22
  • Unique Indexes - probably will not expand support for legacy indexing.
  • Automatic Indexes - "
  • High Availability
  • Traversals - May never be supported due to security concerns. From the manual: "The Traversal REST Endpoint executes arbitrary Groovy code under the hood as part of the evaluators definitions. In hosted and open environments, this can constitute a security risk."
  • Built-In Graph Algorithms
  • Gremlin

Testing

Neoism's test suite respects, but does not require, a NEO4J_URL environment variable. By default it assumes Neo4j is running on localhost:7474, with username neo4j and password foobar.

export NEO4J_URL=http://your_user:[email protected]/db/data/
go test -v .

If you are using a fresh untouched Neo4j instance, you can use the included set_neo4j_password.sh script to set the password to that expected by Neoism's tests:

sh set_neo4j_password.sh

Support

Support and consulting services are available from Silicon Beach Heavy Industries.

Contributing

Contributions in the form of Pull Requests are gladly accepted. Before submitting a PR, please ensure your code passes all tests, and that your changes do not decrease test coverage. I.e. if you add new features also add corresponding new tests.

License

This is Free Software, released under the terms of the GPL v3.

More Repositories

1

napping

Golang HTTP client library
Go
288
star
2

golang-for-python-programmers

work in progress
Python
170
star
3

randutil

Random number/string utility library for Go
Go
63
star
4

o2pro

OAuth2 provider for Golang
Go
41
star
5

jfu

Go backend support for jQuery File Upload plugin
Go
33
star
6

cspace

Communication software of unknown origin, promising unusually high levels of privacy
Python
23
star
7

curriculum-python-for-system-admnistrators

Course curriculum for "Python for eBay System Administrators"
Python
16
star
8

downtest

Runs "go test" on each of the known downstream consumers of a Golang package
Go
12
star
9

tokenizerd

A data tokenization server
Go
9
star
10

restclient

DEPRECATED
Go
8
star
11

jfu-example

Example Go app using the jfu library to support jQuery File Upload plugin
JavaScript
7
star
12

neo4j

RENAMED - see github.com/jmcvetta/neoism
Go
5
star
13

ansible-role-errbot

NOT READY
Python
4
star
14

stormpath

Golang SDK for the Stormpath Identity and Access Manager REST+JSON API
Go
4
star
15

asdf-gitleaks

Gitleaks plugin for asdf version manager
Shell
3
star
16

curriculum-advanced-python

Class curriculum for "Advanced Python"
Python
3
star
17

LiquidFeedback-Heroku

Experimental attempt at deploying LiquidFeedback on Heroku
Lua
3
star
18

ansible-loggly

Ansible role to send syslog to Loggly.com
Ruby
2
star
19

jmcvetta.github.io

Octopress source for http://jmcvetta.github.io
HTML
2
star
20

gopkg

Ruby
2
star
21

ansible-digital_ocean-docker

playing around with ansible, digitial ocean, and docker
Python
1
star
22

esphealth

Python
1
star
23

predictivetext

predictive text
Python
1
star
24

mgourl

MongoDB URL parser, derived from mgo driver's unexported parseUrl() method
Go
1
star
25

curriculum-python-essentials

Curriculum for "Python Essentials" course
Python
1
star
26

facebook

Facebook utilities for Go language
Go
1
star
27

ansible-logzio

Ansible role to forward logs to Logz.io
Ruby
1
star
28

ansible-sentry

Ansible role to deploy Sentry
Python
1
star
29

terraform-provider-rollbar

Vestigial Terraform provider for Rollbar. This is a proof of concept. NOT suitable for use by others. NOT free and open source software.
Go
1
star