Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into decoder_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Solender committed Jul 31, 2020
2 parents 671f070 + 2136adf commit 6257b13
Showing 1 changed file with 71 additions and 73 deletions.
144 changes: 71 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go get -u github.com/mindstand/gogm
- Struct Mapping through the `gogm` struct decorator
- Full support for ACID transactions
- Underlying connection pooling
- Support for HA Casual Clusters using `bolt+routing` through [MindStand's bolt driver](https://github.com/mindstand/go-bolt)
- Support for HA Casual Clusters using `bolt+routing` through the [Official Neo4j Go Driver](https://github.com/neo4j/neo4j-go-driver)
- Custom queries in addition to built in functionality
- Builder pattern cypher queries using [MindStand's cypher dsl package](https://github.com/mindstand/go-cypherdsl)
- CLI to generate link and unlink functions for gogm structs.
Expand Down Expand Up @@ -63,104 +63,102 @@ type MyNeo4jObject struct {
package main

import (
"github.com/mindstand/gogm"
"time"
"github.com/mindstand/gogm"
"time"
)

type tdString string
type tdInt int

//structs for the example (can also be found in decoder_test.go)
type VertexA struct {
// provides required node fields
// provides required node fields
gogm.BaseNode

TestField string `gogm:"name=test_field"`
TestTypeDefString tdString `gogm:"name=test_type_def_string"`
TestTypeDefInt tdInt `gogm:"name=test_type_def_int"`
SingleA *VertexB `gogm:"direction=incoming;relationship=test_rel"`
ManyA []*VertexB `gogm:"direction=incoming;relationship=testm2o"`
MultiA []*VertexB `gogm:"direction=incoming;relationship=multib"`
SingleSpecA *EdgeC `gogm:"direction=outgoing;relationship=special_single"`
MultiSpecA []*EdgeC `gogm:"direction=outgoing;relationship=special_multi"`
TestField string `gogm:"name=test_field"`
TestTypeDefString tdString `gogm:"name=test_type_def_string"`
TestTypeDefInt tdInt `gogm:"name=test_type_def_int"`
SingleA *VertexB `gogm:"direction=incoming;relationship=test_rel"`
ManyA []*VertexB `gogm:"direction=incoming;relationship=testm2o"`
MultiA []*VertexB `gogm:"direction=incoming;relationship=multib"`
SingleSpecA *EdgeC `gogm:"direction=outgoing;relationship=special_single"`
MultiSpecA []*EdgeC `gogm:"direction=outgoing;relationship=special_multi"`
}

type VertexB struct {
// provides required node fields
// provides required node fields
gogm.BaseNode

TestField string `gogm:"name=test_field"`
TestTime time.Time `gogm:"name=test_time"`

Single *VertexA `gogm:"direction=outgoing;relationship=test_rel"`
ManyB *VertexA `gogm:"direction=incoming;relationship=testm2o"`
Multi []*VertexA `gogm:"direction=outgoing;relationship=multib"`

SingleSpec *EdgeC `gogm:"direction=incoming;relationship=special_single"`
MultiSpec []*EdgeC `gogm:"direction=incoming;relationship=special_multi"`
TestField string `gogm:"name=test_field"`
TestTime time.Time `gogm:"name=test_time"`
Single *VertexA `gogm:"direction=outgoing;relationship=test_rel"`
ManyB *VertexA `gogm:"direction=incoming;relationship=testm2o"`
Multi []*VertexA `gogm:"direction=outgoing;relationship=multib"`
SingleSpec *EdgeC `gogm:"direction=incoming;relationship=special_single"`
MultiSpec []*EdgeC `gogm:"direction=incoming;relationship=special_multi"`
}

type EdgeC struct {
// provides required node fields
// provides required node fields
gogm.BaseNode

Start *VertexA
End *VertexB
Test string `gogm:"name=test"`
}

func main(){
config := gogm.Config{
IndexStrategy: gogm.VALIDATE_INDEX, //other options are ASSERT_INDEX and IGNORE_INDEX
PoolSize: 50,
Port: 7687,
IsCluster: false, //tells it whether or not to use `bolt+routing`
Host: "0.0.0.0",
Password: "password",
Username: "neo4j",
}

err := gogm.Init(&config, &VertexA{}, &VertexB{}, &EdgeC{})
if err != nil {
panic(err)
}

//param is readonly, we're going to make stuff so we're going to do read write
sess, err := gogm.NewSession(false)
if err != nil {
panic(err)
}

//close the session
defer sess.Close()

aVal := &VertexA{
TestField: "woo neo4j",
}

bVal := &VertexB{
TestTime: time.Now().UTC(),
}

//set bi directional pointer
bVal.Single = aVal
aVal.SingleA = bVal

err = sess.SaveDepth(&aVal, 2)
if err != nil {
panic(err)
}

//load the object we just made (save will set the uuid)
var readin VertexA
err = sess.Load(&readin, aVal.UUID)
if err != nil {
panic(err)
}


func main() {
config := gogm.Config{
IndexStrategy: gogm.VALIDATE_INDEX, //other options are ASSERT_INDEX and IGNORE_INDEX
PoolSize: 50,
Port: 7687,
IsCluster: false, //tells it whether or not to use `bolt+routing`
Host: "0.0.0.0",
Password: "password",
Username: "neo4j",
}

err := gogm.Init(&config, &VertexA{}, &VertexB{}, &EdgeC{})
if err != nil {
panic(err)
}

//param is readonly, we're going to make stuff so we're going to do read write
sess, err := gogm.NewSession(false)
if err != nil {
panic(err)
}

//close the session
defer sess.Close()

aVal := &VertexA{
TestField: "woo neo4j",
}

bVal := &VertexB{
TestTime: time.Now().UTC(),
}

//set bi directional pointer
bVal.Single = aVal
aVal.SingleA = bVal

err = sess.SaveDepth(&aVal, 2)
if err != nil {
panic(err)
}

//load the object we just made (save will set the uuid)
var readin VertexA
err = sess.Load(&readin, aVal.UUID)
if err != nil {
panic(err)
}

}


```

### GoGM CLI
Expand Down

0 comments on commit 6257b13

Please sign in to comment.