Neo4j client for Golang
Latest commit 2ffb5c6 Mar 6, 2017
Permalink
Failed to load latest commit information.
presentation prettier cypher query formatting Oct 3, 2013
.gitignore ignore IntelliJ's neoism.iml file Dec 29, 2015
.travis.yml test more recent versions of golang Mar 6, 2017
CREDITS.txt add Javier de la Rosa to credits Jul 18, 2013
README.md status table Mar 6, 2017
VERSION bump version to v1.3.1 Dec 29, 2015
benchmark_test.go Adds Google App Engine Support for neoism. Feb 17, 2015
benchmark_test_gae.go Adds Google App Engine Support for neoism. Feb 17, 2015
benchmark_test_standalone.go Adds Google App Engine Support for neoism. Feb 17, 2015
circle.yml override test command Mar 6, 2017
connect.go use gopkg.in to import napping.v3 Oct 6, 2015
connect_gae.go use gopkg.in to import napping.v3 Oct 6, 2015
cypher.go Expose stats via a function Dec 13, 2015
cypher_test.go Merge branch 'develop' into includeStatsOption Dec 29, 2015
database.go use gopkg.in to import napping.v3 Oct 6, 2015
database_test.go respect, but do not require, NEO4J_URL Aug 18, 2015
database_test_gae.go Adds Google App Engine Support for neoism. Feb 17, 2015
database_test_standalone.go Adds Google App Engine Support for neoism. Feb 17, 2015
doc.go Update to Testify assert package Aug 17, 2015
entity.go update calls to db.Session.Delete() for napping v3 API change Oct 6, 2015
error.go Move TxError and TxQueryError from transaction.go to error.go Nov 29, 2014
install_local_neo4j.bash make install script executable Jul 18, 2013
legacy_index.go update calls to db.Session.Delete() for napping v3 API change Oct 6, 2015
neoism.png Rename logo graphic. Aug 26, 2013
neoism.xcf Rename logo graphic. Aug 26, 2013
node.go update calls to db.Session.Delete() for napping v3 API change Oct 6, 2015
node_index.go remove most verbose logging of NeoError Sep 27, 2013
node_index_test.go Update to Testify assert package Aug 17, 2015
node_test.go Update to Testify assert package Aug 17, 2015
rel_index.go Rename package to neoism. Aug 26, 2013
rel_index_test.go Update to Testify assert package Aug 17, 2015
relationship.go remove most verbose logging of NeoError Sep 27, 2013
relationship_test.go Update to Testify assert package Aug 17, 2015
requirements.txt CircleCI configuration files Aug 18, 2015
schema.go Add unique constraint support Nov 14, 2015
schema_test.go Different cleanup for indexes and constraints Dec 18, 2015
set_neo4j_password.sh use previously working neo4j script for travis Aug 18, 2015
start-neo4j.sh test against 2.2.0 with username/password Apr 1, 2015
transaction.go Expose stats via a function Dec 13, 2015
transaction_test.go test stats in the Begin() path Dec 13, 2015
util.go gofmt Sep 2, 2014

README.md

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:your_password@neo4j.yourdomain.com/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.