Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Neo4j client for Golang
Go Shell

Merge pull request #67 from asandeep/app-engine-support

Adds Google App Engine Support for neoism.
latest commit 330a91a709
@jmcvetta authored
Failed to load latest commit information.
presentation prettier cypher query formatting
.gitignore Initial commit
.travis.yml correct path
CREDITS.txt add Javier de la Rosa to credits
README.md README suggestions
benchmark_test.go Adds Google App Engine Support for neoism.
benchmark_test_gae.go Adds Google App Engine Support for neoism.
benchmark_test_standalone.go Adds Google App Engine Support for neoism.
connect.go Adds Google App Engine Support for neoism.
connect_gae.go Adds Google App Engine Support for neoism.
cypher.go remove strip() per #49
cypher_test.go TestCypherComment
database.go Adds Google App Engine Support for neoism.
database_test.go Adds Google App Engine Support for neoism.
database_test_gae.go Adds Google App Engine Support for neoism.
database_test_standalone.go Adds Google App Engine Support for neoism.
doc.go Fix syntax in the cleanup transaction,
entity.go remove most verbose logging of NeoError
error.go Move TxError and TxQueryError from transaction.go to error.go
install_local_neo4j.bash make install script executable
legacy_index.go remove most verbose logging of NeoError
neoism.png Rename logo graphic.
neoism.xcf Rename logo graphic.
node.go Add db references to Rels[] results
node_index.go remove most verbose logging of NeoError
node_index_test.go Rename package to neoism.
node_test.go better 404 handling on create node
rel_index.go Rename package to neoism.
rel_index_test.go Rename package to neoism.
relationship.go remove most verbose logging of NeoError
relationship_test.go Rename package to neoism.
schema.go remove unreachable code
schema_test.go If a blank sting is given as a label, Neo4j now returns all indexes
start-neo4j.sh different neo4j script for travis
transaction.go Move TxError and TxQueryError from transaction.go to error.go
transaction_test.go nodes in parentheses
util.go gofmt

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.

Requirements

Go 1.1 or later is required.

Tested against Neo4j 2.1.2.

Installation

go get -v github.com/jmcvetta/neoism

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
}

Status

Build Status Build Status Coverage Status xrefs funcs top func library users status

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.

Production Note

All API changes will be made via Pull Request, so it's highly recommended you Watch the repo Issues. The API is fairly stable, but there are additions and small changes from time to time.

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)

To Do:

  • Streaming API support - see Issue #22
  • Unique Indexes - probably will not expand support for legacy indexing.
  • Automatic Indexes - "
  • High Availability
  • Authentication (in neo4j 2.2)
  • 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

Contributing

Contributions, in the form of Pull Requests or Issues, are gladly accepted. Before submitting a Pull Request, 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.

For fastest response when submitting an Issue, please create a failing test case to demonstrate the problem.

Support

Paid support, development, related professional services, and proprietary licensing terms for this package are available from from the author.

License

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

Something went wrong with that request. Please try again.