https://github.com/bbuck/talon
Talon is a Neo4j ORM to simply working between the database and Go.
https://github.com/bbuck/talon
Last synced: 11 months ago
JSON representation
Talon is a Neo4j ORM to simply working between the database and Go.
- Host: GitHub
- URL: https://github.com/bbuck/talon
- Owner: bbuck
- License: mit
- Created: 2016-10-15T14:06:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-29T18:23:42.000Z (about 9 years ago)
- Last Synced: 2024-06-20T16:50:04.060Z (over 1 year ago)
- Language: Go
- Size: 31.3 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pre-alpha!
This project is in a pre-alpha phase. It's not ready for use or consumption.
At such a time the basic features are implmented I'll create a v0 tag for
gopkg to use and remove this banner.
# Goals
I'm trying to simplify dynamic Neo4j querying by creating constructs to build
Cypher queries in Code in steps or all at once and allow working with Go
structs. For example, a common usage may be aligning stucts to node labels in
Neo4j and so at it's simplest:
```go
type Person struct {
ID int `talon:"id"`
Firstname string `talon:"firstname"`
Lastname string `talon:"lastname"`
}
p := Person{ID: 1}
db.Find(&p)
```
Which will query the database `MATCH (_ref1:Person {id: 1}) RETURN _ref1` and
once the command has executed you're free to use the properties freely.
The other thing is building Cypher queries in code:
```go
db.Match(
Node()
.Named("a")
.Labeled("Person")
.WithProperties(talon.Properties{
"id": 1,
})
).Retrun("a").String()
```
Produces a similar query as fetching the raw struct: `MATCH (a:Person {id: 1}) RETURN a`.
From the point of having a query you can easily load single rows into structs: `query.LoadResult(&p)
or work with many rows:
```go
var people []Person
db.Match(Node().Named("a").Labeled("Person")).Return("a").LoadResults(&people)
```