https://github.com/rlch/neogo
A Golang-ORM for Neo4J which creates idiomatic & fluent Cypher.
https://github.com/rlch/neogo
Last synced: 4 months ago
JSON representation
A Golang-ORM for Neo4J which creates idiomatic & fluent Cypher.
- Host: GitHub
- URL: https://github.com/rlch/neogo
- Owner: rlch
- License: mit
- Created: 2023-07-28T08:53:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T03:15:49.000Z (about 1 year ago)
- Last Synced: 2024-04-17T17:09:14.216Z (about 1 year ago)
- Language: Go
- Size: 233 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# neogo

[](https://goreportcard.com/report/github.com/rlch/neogo) [](https://codecov.io/gh/rlch/neogo) [](https://pkg.go.dev/github.com/rlch/neogo)
A Golang-ORM for Neo4J which creates idiomatic & fluent Cypher.
> [!WARNING]
> The neogo API is still in an experimental phase. Expect minor changes and
> additions until the first release.## Overview
`neogo` was designed to make writing Cypher as simple as possible, providing a
safety-net and reducing boilerplate by leveraging canonical representations of
nodes and relationships as Golang structs.- Hands-free un/marshalling between Go and Neo4J
- No dynamic property, variable, label qualification necessary
- Creates readable, interoperable Cypher queries
- Abstract nodes with multiple concrete implementers
- Heavily tested; full coverage of Neo4J docs examples (see `internal/tests`)
- Automatic & explicit:
- Variable qualification
- Node/relationship label patterns
- Parameter injection## Getting Started
See the following resources to get started with `neogo`:
- [Docs](https://pkg.go.dev/github.com/rlch/neogo)
- [Tests](https://github.com/rlch/neogo/tree/main/internal/tests)
- [Official driver](https://github.com/neo4j/neo4j-go-driver)## Example
```go
type Person struct {
neogo.Node `neo4j:"Person"`Name string `json:"name"`
Surname string `json:"surname"`
Age int `json:"age"`
}func main() {
// Simply obtain an instance of the neo4j.DriverWithContext
d := neogo.New(driverWithContext)person := Person{
Name: "Spongebob",
Surname: "Squarepants",
}
// person.GenerateID() can be used
person.ID = "some-unique-id"err := d.Exec().
Create(db.Node(&person)).
Set(db.SetPropValue(&person.Age, 20)).
Return(&person).
Print().
Run(ctx)
// Output:
// CREATE (person:Person {name: $person_name, surname: $person_surname})
// SET person.age = $v1
// RETURN personfmt.Printf("person: %v\n", person)
// Output:
// person: {{some-unique-id} Spongebob Squarepants 20}
}
```## Contributions
See [the contributing guide](CONTRIBUTING.md) for detailed instructions on how to start contibuting to `neogo`.