neoism

Neo4j client for Golang

  • 所有者: jmcvetta/neoism
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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
.

主要指标

概览
名称与所有者jmcvetta/neoism
主编程语言Go
编程语言Go (语言数: 2)
平台
许可证
所有者活动
创建于2012-07-12 07:42:33
推送于2020-02-16 09:28:03
最后一次提交2017-03-06 17:41:37
发布数6
最新版本名称v1.3.1 (发布于 2015-12-29 11:40:10)
第一版名称v1.1.0 (发布于 2015-08-18 18:29:55)
用户参与
星数390
关注者数23
派生数54
提交数517
已启用问题?
问题数62
打开的问题数10
拉请求数36
打开的拉请求数2
关闭的拉请求数15
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?