Skip to content
/ neogo Public

A Golang-ORM for Neo4J which creates idiomatic & fluent Cypher.

License

Notifications You must be signed in to change notification settings

rlch/neogo

Repository files navigation

neogo

logo

Go Report Card codecov Go Reference

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:

Example

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 person

    fmt.Printf("person: %v\n", person)
    // Output:
    // person: {{some-unique-id} Spongebob Squarepants 20}
}

Contributions

See the contributing guide for detailed instructions on how to start contibuting to neogo.

About

A Golang-ORM for Neo4J which creates idiomatic & fluent Cypher.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages