From 1fad90e8548901339d9fd7a37bc90397a3938f39 Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Wed, 25 Sep 2013 17:58:04 -0700 Subject: [PATCH 1/7] work on conversion from restclient to napping --- cypher.go | 37 +++++++----------- database.go | 24 ++++++------ entity.go | 101 +++++++++++++++--------------------------------- legacy_index.go | 82 +++++++++++++-------------------------- 4 files changed, 84 insertions(+), 160 deletions(-) diff --git a/cypher.go b/cypher.go index a8e314f..a0dab16 100644 --- a/cypher.go +++ b/cypher.go @@ -7,7 +7,6 @@ package neoism import ( "encoding/json" "errors" - "github.com/jmcvetta/restclient" ) // A CypherQuery is a statement in the Cypher query language, with optional @@ -64,28 +63,28 @@ type cypherResult struct { // from the db is used to populate `result`, which should be a pointer to a // slice of structs. TODO: Or a pointer to a two-dimensional array of structs? func (db *Database) Cypher(q *CypherQuery) error { - cRes := cypherResult{} - cReq := cypherRequest{ + result := cypherResult{} + payload := cypherRequest{ Query: q.Statement, Parameters: q.Parameters, } ne := new(NeoError) - rr := restclient.RequestResponse{ - Url: db.HrefCypher, - Method: "POST", - Data: &cReq, - Result: &cRes, - Error: ne, - } - status, err := db.Rc.Do(&rr) + url := db.HrefCypher + // Method: "POST" + // Data: &cReq + // Result: &cRes + // Error: ne + // } + resp, err := db.Session.Post(url, &payload, &result, nil) if err != nil { return err } - if status != 200 { + if resp.Status() != 200 { + resp.Unmarshall(ne) logPretty(ne) return *ne } - q.cr = cRes + q.cr = result if q.Result != nil { q.Unmarshal(q.Result) } @@ -124,18 +123,12 @@ func (db *Database) CypherBatch(qs []*CypherQuery) error { } res := []batchCypherResponse{} ne := NeoError{} - rr := restclient.RequestResponse{ - Url: db.HrefBatch, - Method: "POST", - Data: payload, - Result: &res, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + url := db.HrefBatch + resp, err := db.Session.Post(url, payload, &res, nil) if err != nil { return err } - if status != 200 { + if resp.Status() != 200 { logPretty(ne) return ne } diff --git a/database.go b/database.go index 85b3d8e..f136e0a 100644 --- a/database.go +++ b/database.go @@ -5,6 +5,7 @@ package neoism import ( + "github.com/jmcvetta/napping" "github.com/jmcvetta/restclient" "log" "net/url" @@ -14,6 +15,7 @@ import ( // A Database is a REST client connected to a Neo4j database. type Database struct { Rc *restclient.Client + Session *napping.Session Url string `json:"-"` // Root URL for REST API HrefNode string `json:"node"` HrefRefNode string `json:"reference_node"` @@ -30,28 +32,26 @@ type Database struct { // Connect establishes a connection to the Neo4j server. func Connect(uri string) (*Database, error) { - var e NeoError db := &Database{ - Rc: restclient.New(), + Rc: restclient.New(), + Session: &napping.Session{}, } _, err := url.Parse(uri) // Sanity check if err != nil { return nil, err } db.Url = uri - req := restclient.RequestResponse{ - Url: db.Url, - Method: "GET", - Result: &db, - Error: &e, - } - status, err := db.Rc.Do(&req) + // Url: db.Url, + // Method: "GET", + // Result: &db, + // Error: &e, + resp, err := db.Session.Get(db.Url, nil, &db, nil) if err != nil { return nil, err } - if status != 200 || db.Version == "" { - logPretty(req.RawText) - log.Println("Status " + strconv.Itoa(status) + " trying to connect to " + uri) + if resp.Status() != 200 || db.Version == "" { + logPretty(resp.RawText()) + log.Println("Status " + strconv.Itoa(resp.Status()) + " trying to connect to " + uri) return nil, InvalidDatabase } return db, nil diff --git a/entity.go b/entity.go index 515c709..7691ec8 100644 --- a/entity.go +++ b/entity.go @@ -5,7 +5,6 @@ package neoism import ( - "github.com/jmcvetta/restclient" "strings" ) @@ -19,27 +18,17 @@ type entity struct { HrefProperties string `json:"properties"` } -// do is a convenience wrapper around the embedded restclient's Do() method. -func (e *entity) do(rr *restclient.RequestResponse) (status int, err error) { - return e.Db.Rc.Do(rr) -} - // SetProperty sets the single property key to value. func (e *entity) SetProperty(key string, value string) error { parts := []string{e.HrefProperties, key} - uri := strings.Join(parts, "/") - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: uri, - Method: "PUT", - Data: &value, - Error: &ne, - } - status, err := e.do(&rr) + url := strings.Join(parts, "/") + resp, err := e.Db.Session.Put(url, &value, nil, nil) if err != nil { return err } - if status != 204 { + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshall(&ne) return ne } return nil // Success! @@ -49,23 +38,19 @@ func (e *entity) SetProperty(key string, value string) error { func (e *entity) Property(key string) (string, error) { var val string parts := []string{e.HrefProperties, key} - uri := strings.Join(parts, "/") - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: uri, - Method: "GET", - Result: &val, - Error: &ne, - } - status, err := e.do(&rr) + url := strings.Join(parts, "/") + resp, err := e.Db.Session.Get(url, nil, &val, nil) if err != nil { + logPretty(err) return val, err } - switch status { + switch resp.Status() { case 200: case 404: return val, NotFound default: + ne := NeoError{} + resp.Unmarshall(&ne) return val, ne } return val, nil // Success! @@ -74,47 +59,39 @@ func (e *entity) Property(key string) (string, error) { // DeleteProperty deletes property key func (e *entity) DeleteProperty(key string) error { parts := []string{e.HrefProperties, key} - uri := strings.Join(parts, "/") - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: uri, - Method: "DELETE", - Error: &ne, - } - status, err := e.do(&rr) + url := strings.Join(parts, "/") + resp, err := e.Db.Session.Delete(url, nil) if err != nil { return err } - switch status { + switch resp.Status() { case 204: return nil // Success! case 404: return NotFound } + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return ne } // Delete removes the object from the DB. func (e *entity) Delete() error { - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: e.HrefSelf, - Method: "DELETE", - Error: &ne, - } - status, err := e.do(&rr) + resp, err := e.Db.Session.Delete(e.HrefSelf, nil) if err != nil { return err } - switch status { + switch resp.Status() { case 204: case 404: return NotFound case 409: return CannotDelete default: - logPretty(status) + ne := NeoError{} + resp.Unmarshall(&ne) + logPretty(resp.Status()) logPretty(ne) return ne } @@ -124,19 +101,12 @@ func (e *entity) Delete() error { // Properties fetches all properties func (e *entity) Properties() (Props, error) { props := Props{} - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: e.HrefProperties, - Method: "GET", - Result: &props, - Error: &ne, - } - status, err := e.do(&rr) + resp, err := e.Db.Session.Get(e.HrefProperties, nil, &props, nil) if err != nil { return props, err } // Status code 204 indicates no properties on this node - if status == 204 { + if resp.Status() == 204 { props = Props{} } return props, nil @@ -144,42 +114,33 @@ func (e *entity) Properties() (Props, error) { // SetProperties updates all properties, overwriting any existing properties. func (e *entity) SetProperties(p Props) error { - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: e.HrefProperties, - Method: "PUT", - Data: &p, - Error: &ne, - } - status, err := e.do(&rr) + resp, err := e.Db.Session.Put(e.HrefProperties, &p, nil, nil) if err != nil { return err } - if status == 204 { + if resp.Status() == 204 { return nil // Success! } + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return ne } // DeleteProperties deletes all properties. func (e *entity) DeleteProperties() error { - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: e.HrefProperties, - Method: "DELETE", - Error: &ne, - } - status, err := e.do(&rr) + resp, err := e.Db.Session.Delete(e.HrefProperties, nil) if err != nil { return err } - switch status { + switch resp.Status() { case 204: return nil // Success! case 404: return NotFound } + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return ne } diff --git a/legacy_index.go b/legacy_index.go index 099fa0f..751046a 100644 --- a/legacy_index.go +++ b/legacy_index.go @@ -5,7 +5,6 @@ package neoism import ( - "github.com/jmcvetta/restclient" "net/url" ) @@ -32,21 +31,14 @@ func (db *Database) createIndex(href, name, idxType, provider string) (*index, e payload.Config = config } res := new(indexResponse) - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: href, - Method: "POST", - Data: &payload, - Result: res, - Error: &ne, - ExpectedStatus: 201, - } - status, err := db.Rc.Do(&rr) + resp, err := db.Session.Post(href, &payload, &res, nil) if err != nil { logPretty(err) return nil, err } - if status != 201 { + if resp.Status() != 201 { + ne := NeoError{} + resp.Unmarshall(&ne) return nil, ne } idx.populate(res) @@ -57,18 +49,13 @@ func (db *Database) createIndex(href, name, idxType, provider string) (*index, e func (db *Database) indexes(href string) ([]*index, error) { res := map[string]indexResponse{} nis := []*index{} - ne := NeoError{} - req := restclient.RequestResponse{ - Url: href, - Method: "GET", - Result: &res, - Error: &ne, - } - status, err := db.Rc.Do(&req) + resp, err := db.Session.Get(href, nil, &res, nil) if err != nil { return nis, err } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return nis, ne } @@ -93,22 +80,18 @@ func (db *Database) index(href, name string) (*index, error) { if err != nil { return idx, err } - ne := NeoError{} - req := restclient.RequestResponse{ - Url: u.String(), - Method: "GET", - Error: &ne, - } - status, err := db.Rc.Do(&req) + resp, err := db.Session.Get(u.String(), nil, nil, nil) if err != nil { return nil, err } - switch status { + switch resp.Status() { // Success! case 200: case 404: return nil, NotFound default: + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return idx, ne } @@ -154,17 +137,13 @@ func (idx *index) Delete() error { if err != nil { return err } - ne := NeoError{} - req := restclient.RequestResponse{ - Url: uri, - Method: "DELETE", - Error: &ne, - } - status, err := idx.db.Rc.Do(&req) + resp, err := idx.db.Session.Delete(uri, nil) if err != nil { return err } - if status != 204 { + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return ne } @@ -177,28 +156,23 @@ func (idx *index) add(e entity, key string, value interface{}) error { if err != nil { return err } - ne := NeoError{} type s struct { Uri string `json:"uri"` Key string `json:"key"` Value interface{} `json:"value"` } - data := s{ + payload := s{ Uri: e.HrefSelf, Key: key, Value: value, } - req := restclient.RequestResponse{ - Url: uri, - Method: "POST", - Data: data, - Error: &ne, - } - status, err := idx.db.Rc.Do(&req) + resp, err := idx.db.Session.Post(uri, &payload, nil, nil) if err != nil { return err } - if status != 201 { + if resp.Status() != 201 { + ne := NeoError{} + resp.Unmarshall(&ne) logPretty(ne) return ne } @@ -218,18 +192,14 @@ func (idx *index) remove(e entity, id, key, value string) error { uri = join(uri, key, value) } uri = join(uri, id) - ne := NeoError{} - req := restclient.RequestResponse{ - Url: uri, - Method: "DELETE", - Error: &ne, - } - status, err := idx.db.Rc.Do(&req) + resp, err := idx.db.Session.Delete(uri, nil) if err != nil { return err } - if status != 204 { - logPretty(req) + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshall(&ne) + logPretty(ne) return ne } return nil // Success! From e4f74ec68eb33bb31166f8e423015eb19d133090 Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Wed, 25 Sep 2013 18:36:53 -0700 Subject: [PATCH 2/7] convert from restclient to napping --- node.go | 150 ++++++++++++++++++-------------------------------------- 1 file changed, 49 insertions(+), 101 deletions(-) diff --git a/node.go b/node.go index 615cb02..e28a502 100644 --- a/node.go +++ b/node.go @@ -5,7 +5,6 @@ package neoism import ( - "github.com/jmcvetta/restclient" "strconv" "strings" ) @@ -14,18 +13,11 @@ import ( func (db *Database) CreateNode(p Props) (*Node, error) { n := Node{} n.Db = db - ne := new(NeoError) - rr := restclient.RequestResponse{ - Url: db.HrefNode, - Method: "POST", - Data: &p, - Result: &n, - Error: ne, - ExpectedStatus: 201, - } - status, err := db.Rc.Do(&rr) - if err != nil { - logPretty(status) + resp, err := db.Session.Post(db.HrefNode, &p, &n, nil) + if err != nil || resp.Status() != 201 { + logPretty(resp.Status()) + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) return &n, err } @@ -40,23 +32,19 @@ func (db *Database) Node(id int) (*Node, error) { // getNodeByUri fetches a Node from the database based on its URI. func (db *Database) getNodeByUri(uri string) (*Node, error) { - ne := NeoError{} n := Node{} n.Db = db - rr := restclient.RequestResponse{ - Url: uri, - Method: "GET", - Result: &n, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + resp, err := db.Session.Get(uri, nil, &n, nil) if err != nil { return nil, err } + status := resp.Status() switch { case status == 404: return &n, NotFound case status != 200 || n.HrefSelf == "": + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) return nil, ne } @@ -101,18 +89,13 @@ func (n *Node) getRels(uri string, types ...string) (Rels, error) { uri = strings.Join(parts, "/") } rels := Rels{} - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: uri, - Method: "GET", - Result: &rels, - Error: &ne, - } - status, err := n.Db.Rc.Do(&rr) + resp, err := n.Db.Session.Get(uri, nil, &rels, nil) if err != nil { return rels, err } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) return rels, ne } @@ -140,7 +123,6 @@ func (n *Node) Outgoing(types ...string) (Rels, error) { func (n *Node) Relate(relType string, destId int, p Props) (*Relationship, error) { rel := Relationship{} rel.Db = n.Db - ne := NeoError{} srcUri := join(n.HrefSelf, "relationships") destUri := join(n.Db.HrefNode, strconv.Itoa(destId)) content := map[string]interface{}{ @@ -150,18 +132,13 @@ func (n *Node) Relate(relType string, destId int, p Props) (*Relationship, error if p != nil { content["data"] = &p } - c := restclient.RequestResponse{ - Url: srcUri, - Method: "POST", - Data: content, - Result: &rel, - Error: &ne, - } - status, err := n.Db.Rc.Do(&c) + resp, err := n.Db.Session.Post(srcUri, content, &rel, nil) if err != nil { return &rel, err } - if status != 201 { + if resp.Status() != 201 { + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) return &rel, ne } @@ -170,21 +147,16 @@ func (n *Node) Relate(relType string, destId int, p Props) (*Relationship, error // AddLabels adds one or more labels to a node. func (n *Node) AddLabel(labels ...string) error { - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: n.HrefLabels, - Method: "POST", - Data: labels, - Error: &ne, - } - status, err := n.Db.Rc.Do(&rr) + resp, err := n.Db.Session.Post(n.HrefLabels, labels, nil, nil) if err != nil { return err } - if status == 404 { + if resp.Status() == 404 { return NotFound } - if status != 204 { + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshal(&ne) return ne } return nil // Success @@ -192,22 +164,17 @@ func (n *Node) AddLabel(labels ...string) error { // Labels lists labels for a node. func (n *Node) Labels() ([]string, error) { - ne := NeoError{} res := []string{} - rr := restclient.RequestResponse{ - Url: n.HrefLabels, - Method: "GET", - Error: &ne, - Result: &res, - } - status, err := n.Db.Rc.Do(&rr) + resp, err := n.Db.Session.Get(n.HrefLabels, nil, &res, nil) if err != nil { return res, err } - if status == 404 { + if resp.Status() == 404 { return res, NotFound } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) return res, ne } return res, nil // Success @@ -215,21 +182,17 @@ func (n *Node) Labels() ([]string, error) { // RemoveLabel removes a label from a node. func (n *Node) RemoveLabel(label string) error { - ne := NeoError{} - url := join(n.HrefLabels, label) - rr := restclient.RequestResponse{ - Url: url, - Method: "DELETE", - Error: &ne, - } - status, err := n.Db.Rc.Do(&rr) + uri := join(n.HrefLabels, label) + resp, err := n.Db.Session.Delete(uri, nil) if err != nil { return err } - if status == 404 { + if resp.Status() == 404 { return NotFound } - if status != 204 { + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshal(&ne) return ne } return nil // Success @@ -238,21 +201,16 @@ func (n *Node) RemoveLabel(label string) error { // SetLabels removes any labels currently on a node, and replaces them with the // labels provided as argument. func (n *Node) SetLabels(labels []string) error { - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: n.HrefLabels, - Method: "PUT", - Data: labels, - Error: &ne, - } - status, err := n.Db.Rc.Do(&rr) + resp, err := n.Db.Session.Put(n.HrefLabels, labels, nil, nil) if err != nil { return err } - if status == 404 { + if resp.Status() == 404 { return NotFound } - if status != 204 { + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshal(&ne) return ne } return nil // Success @@ -260,23 +218,18 @@ func (n *Node) SetLabels(labels []string) error { // NodesByLabel gets all nodes with a given label. func (db *Database) NodesByLabel(label string) ([]*Node, error) { - url := join(db.Url, "label", label, "nodes") - ne := NeoError{} + uri := join(db.Url, "label", label, "nodes") res := []*Node{} - rr := restclient.RequestResponse{ - Url: url, - Method: "GET", - Result: &res, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + resp, err := db.Session.Get(uri, nil, &res, nil) if err != nil { return res, err } - if status == 404 { + if resp.Status() == 404 { return res, NotFound } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) return res, ne } for _, n := range res { @@ -287,20 +240,15 @@ func (db *Database) NodesByLabel(label string) ([]*Node, error) { // Labels lists all labels. func (db *Database) Labels() ([]string, error) { - url := join(db.Url, "labels") - ne := NeoError{} + uri := join(db.Url, "labels") labels := []string{} - rr := restclient.RequestResponse{ - Url: url, - Method: "GET", - Result: &labels, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + resp, err := db.Session.Get(uri, nil, &labels, nil) if err != nil { return labels, err } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) return labels, ne } return labels, nil From 7a7c1982fbad20e4164c501a5a42650f0de61bd4 Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Wed, 25 Sep 2013 18:37:13 -0700 Subject: [PATCH 3/7] correct spelling of "unmarshal" --- cypher.go | 2 +- entity.go | 12 ++++++------ legacy_index.go | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cypher.go b/cypher.go index a0dab16..faa4bb3 100644 --- a/cypher.go +++ b/cypher.go @@ -80,7 +80,7 @@ func (db *Database) Cypher(q *CypherQuery) error { return err } if resp.Status() != 200 { - resp.Unmarshall(ne) + resp.Unmarshal(ne) logPretty(ne) return *ne } diff --git a/entity.go b/entity.go index 7691ec8..4096b69 100644 --- a/entity.go +++ b/entity.go @@ -28,7 +28,7 @@ func (e *entity) SetProperty(key string, value string) error { } if resp.Status() != 204 { ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) return ne } return nil // Success! @@ -50,7 +50,7 @@ func (e *entity) Property(key string) (string, error) { return val, NotFound default: ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) return val, ne } return val, nil // Success! @@ -71,7 +71,7 @@ func (e *entity) DeleteProperty(key string) error { return NotFound } ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return ne } @@ -90,7 +90,7 @@ func (e *entity) Delete() error { return CannotDelete default: ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(resp.Status()) logPretty(ne) return ne @@ -122,7 +122,7 @@ func (e *entity) SetProperties(p Props) error { return nil // Success! } ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return ne } @@ -140,7 +140,7 @@ func (e *entity) DeleteProperties() error { return NotFound } ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return ne } diff --git a/legacy_index.go b/legacy_index.go index 751046a..a7c5205 100644 --- a/legacy_index.go +++ b/legacy_index.go @@ -38,7 +38,7 @@ func (db *Database) createIndex(href, name, idxType, provider string) (*index, e } if resp.Status() != 201 { ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) return nil, ne } idx.populate(res) @@ -55,7 +55,7 @@ func (db *Database) indexes(href string) ([]*index, error) { } if resp.Status() != 200 { ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return nis, ne } @@ -91,7 +91,7 @@ func (db *Database) index(href, name string) (*index, error) { return nil, NotFound default: ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return idx, ne } @@ -143,7 +143,7 @@ func (idx *index) Delete() error { } if resp.Status() != 204 { ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return ne } @@ -172,7 +172,7 @@ func (idx *index) add(e entity, key string, value interface{}) error { } if resp.Status() != 201 { ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return ne } @@ -198,7 +198,7 @@ func (idx *index) remove(e entity, id, key, value string) error { } if resp.Status() != 204 { ne := NeoError{} - resp.Unmarshall(&ne) + resp.Unmarshal(&ne) logPretty(ne) return ne } From 34e30e591e5c862cf73744de63e2e2b2d61aa08b Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Wed, 25 Sep 2013 18:40:37 -0700 Subject: [PATCH 4/7] convert from restclient to napping --- node_index.go | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/node_index.go b/node_index.go index 97f57db..872d0d6 100644 --- a/node_index.go +++ b/node_index.go @@ -5,7 +5,6 @@ package neoism import ( - "github.com/jmcvetta/restclient" "net/url" "strconv" ) @@ -72,23 +71,18 @@ func (idx *LegacyNodeIndex) Find(key, value string) (map[int]*Node, error) { if err != nil { return nm, err } - ne := NeoError{} - resp := []Node{} - req := restclient.RequestResponse{ - Url: u.String(), - Method: "GET", - Result: &resp, - Error: &ne, - } - status, err := idx.db.Rc.Do(&req) + result := []Node{} + resp, err := idx.db.Session.Get(u.String(), nil, &result, nil) if err != nil { return nm, err } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) return nm, ne } - for _, n := range resp { + for _, n := range result { n.Db = idx.db nm[n.Id()] = &n } @@ -110,19 +104,14 @@ func (idx *index) Query(query string) (map[int]*Node, error) { return nm, err } result := []Node{} - ne := NeoError{} - req := restclient.RequestResponse{ - Url: u.String(), - Method: "GET", - Result: &result, - Error: &ne, - } - status, err := idx.db.Rc.Do(&req) + resp, err := idx.db.Session.Get(u.String(), nil, &result, nil) if err != nil { return nm, err } - if status != 200 { - logPretty(req) + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) + logPretty(ne) return nm, ne } for _, n := range result { From c28fe337921a1b1f2d42396de6f5fe828b80acec Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Wed, 25 Sep 2013 18:58:42 -0700 Subject: [PATCH 5/7] convert from restclient to napping --- database.go | 3 -- database_test.go | 2 +- relationship.go | 27 ++++++----------- schema.go | 75 ++++++++++++++++++------------------------------ transaction.go | 75 +++++++++++++++++------------------------------- 5 files changed, 64 insertions(+), 118 deletions(-) diff --git a/database.go b/database.go index f136e0a..536f7a9 100644 --- a/database.go +++ b/database.go @@ -6,7 +6,6 @@ package neoism import ( "github.com/jmcvetta/napping" - "github.com/jmcvetta/restclient" "log" "net/url" "strconv" @@ -14,7 +13,6 @@ import ( // A Database is a REST client connected to a Neo4j database. type Database struct { - Rc *restclient.Client Session *napping.Session Url string `json:"-"` // Root URL for REST API HrefNode string `json:"node"` @@ -33,7 +31,6 @@ type Database struct { // Connect establishes a connection to the Neo4j server. func Connect(uri string) (*Database, error) { db := &Database{ - Rc: restclient.New(), Session: &napping.Session{}, } _, err := url.Parse(uri) // Sanity check diff --git a/database_test.go b/database_test.go index e8196cb..d1f2b76 100644 --- a/database_test.go +++ b/database_test.go @@ -79,7 +79,7 @@ func TestConnectInvalidUrl(t *testing.T) { t.Fatal("Expected error due to missing protocol scheme") } // - // Unsupported protocol scheme - restclient.Do should fail + // Unsupported protocol scheme - Session.Get should fail // _, err = Connect("foo://bar.com") if err == nil { diff --git a/relationship.go b/relationship.go index de02fbe..68a9a7e 100644 --- a/relationship.go +++ b/relationship.go @@ -5,7 +5,6 @@ package neoism import ( - "github.com/jmcvetta/restclient" "sort" "strconv" "strings" @@ -16,19 +15,14 @@ func (db *Database) Relationship(id int) (*Relationship, error) { rel := Relationship{} rel.Db = db uri := join(db.Url, "relationship", strconv.Itoa(id)) - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: uri, - Method: "GET", - Result: &rel, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + resp, err := db.Session.Get(uri, nil, &rel, nil) if err != nil { return &rel, err } - switch status { + switch resp.Status() { default: + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) err = ne case 200: @@ -42,21 +36,16 @@ func (db *Database) Relationship(id int) (*Relationship, error) { // Types lists all existing relationship types func (db *Database) RelTypes() ([]string, error) { reltypes := []string{} - ne := NeoError{} - c := restclient.RequestResponse{ - Url: db.HrefRelTypes, - Method: "GET", - Result: &reltypes, - Error: &ne, - } - status, err := db.Rc.Do(&c) + resp, err := db.Session.Get(db.HrefRelTypes, nil, &reltypes, nil) if err != nil { return reltypes, err } - if status == 200 { + if resp.Status() == 200 { sort.Sort(sort.StringSlice(reltypes)) return reltypes, nil // Success! } + ne := NeoError{} + resp.Unmarshal(&ne) logPretty(ne) return reltypes, ne } diff --git a/schema.go b/schema.go index f16fb49..270b19a 100644 --- a/schema.go +++ b/schema.go @@ -4,10 +4,6 @@ package neoism -import ( - "github.com/jmcvetta/restclient" -) - type indexRequest struct { PropertyKeys []string `json:"property_keys"` } @@ -21,21 +17,17 @@ type Index struct { // Drop removes the index. func (idx *Index) Drop() error { - url := join(idx.db.Url, "schema/index", idx.Label, idx.PropertyKeys[0]) - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: url, - Method: "DELETE", - Error: &ne, - } - status, err := idx.db.Rc.Do(&rr) + uri := join(idx.db.Url, "schema/index", idx.Label, idx.PropertyKeys[0]) + resp, err := idx.db.Session.Delete(uri, nil) if err != nil { return err } - if status == 404 { + if resp.Status() == 404 { return NotFound } - if status != 204 { + if resp.Status() != 204 { + ne := NeoError{} + resp.Unmarshal(&ne) return ne } return nil @@ -44,53 +36,42 @@ func (idx *Index) Drop() error { // CreateIndex starts a background job in the database that will create and // populate the new index of a specified property on nodes of a given label. func (db *Database) CreateIndex(label, property string) (*Index, error) { - url := join(db.Url, "schema/index", label) + uri := join(db.Url, "schema/index", label) payload := indexRequest{[]string{property}} - ne := NeoError{} - res := Index{db: db} - rr := restclient.RequestResponse{ - Url: url, - Method: "POST", - Data: payload, - Result: &res, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + result := Index{db: db} + resp, err := db.Session.Post(uri, payload, &result, nil) if err != nil { return nil, err } - if status == 404 { + switch resp.Status() { + case 200: + return &result, nil // Success + case 404: return nil, NotFound } - if status != 200 { - return nil, ne - } - return &res, nil + ne := NeoError{} + resp.Unmarshal(&ne) + return nil, ne } // Indexes lists indexes for a label. func (db *Database) Indexes(label string) ([]*Index, error) { - url := join(db.Url, "schema/index", label) - ne := NeoError{} - res := []*Index{} - rr := restclient.RequestResponse{ - Url: url, - Method: "GET", - Result: &res, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + uri := join(db.Url, "schema/index", label) + result := []*Index{} + resp, err := db.Session.Get(uri, nil, &result, nil) if err != nil { - return res, err + return result, err } - if status == 404 { - return res, NotFound + if resp.Status() == 404 { + return result, NotFound } - if status != 200 { - return res, ne + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) + return result, ne } - for _, idx := range res { + for _, idx := range result { idx.db = db } - return res, nil + return result, nil } diff --git a/transaction.go b/transaction.go index e5074a9..77114f8 100644 --- a/transaction.go +++ b/transaction.go @@ -6,7 +6,6 @@ package neoism import ( "errors" - "github.com/jmcvetta/restclient" ) // A Tx is an in-progress database transaction. @@ -62,31 +61,25 @@ func (tr *txResponse) unmarshal(qs []*CypherQuery) error { // Begin opens a new transaction, executing zero or more cypher queries // inside the transaction. func (db *Database) Begin(qs []*CypherQuery) (*Tx, error) { - ne := NeoError{} payload := txRequest{Statements: qs} - res := txResponse{} - rr := restclient.RequestResponse{ - Url: db.HrefTransaction, - Method: "POST", - Data: payload, - Result: &res, - Error: &ne, - } - status, err := db.Rc.Do(&rr) + result := txResponse{} + resp, err := db.Session.Post(db.HrefTransaction, payload, &result, nil) if err != nil { return nil, err } - if status != 201 { + if resp.Status() != 201 { + ne := NeoError{} + resp.Unmarshal(&ne) return nil, ne } t := Tx{ db: db, - hrefCommit: res.Commit, - Location: rr.HttpResponse.Header.Get("location"), - Errors: res.Errors, - Expires: res.Transaction.Expires, + hrefCommit: result.Commit, + Location: resp.HttpResponse().Header.Get("location"), + Errors: result.Errors, + Expires: result.Transaction.Expires, } - err = res.unmarshal(qs) + err = result.unmarshal(qs) if err != nil { return &t, err } @@ -101,17 +94,13 @@ func (t *Tx) Commit() error { if len(t.Errors) > 0 { return TxQueryError } - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: t.hrefCommit, - Method: "POST", - Error: &ne, - } - status, err := t.db.Rc.Do(&rr) + resp, err := t.db.Session.Post(t.hrefCommit, nil, nil, nil) if err != nil { return err } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) return ne } return nil // Success @@ -119,29 +108,23 @@ func (t *Tx) Commit() error { // Query executes statements in an open transaction. func (t *Tx) Query(qs []*CypherQuery) error { - ne := NeoError{} payload := txRequest{Statements: qs} - res := txResponse{} - rr := restclient.RequestResponse{ - Url: t.Location, - Method: "POST", - Data: payload, - Result: &res, - Error: &ne, - } - status, err := t.db.Rc.Do(&rr) + result := txResponse{} + resp, err := t.db.Session.Post(t.Location, payload, &result, nil) if err != nil { return err } - if status == 404 { + if resp.Status() == 404 { return NotFound } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) return &ne } - t.Expires = res.Transaction.Expires - t.Errors = append(t.Errors, res.Errors...) - err = res.unmarshal(qs) + t.Expires = result.Transaction.Expires + t.Errors = append(t.Errors, result.Errors...) + err = result.unmarshal(qs) if err != nil { return err } @@ -153,17 +136,13 @@ func (t *Tx) Query(qs []*CypherQuery) error { // Rollback rolls back an open transaction. func (t *Tx) Rollback() error { - ne := NeoError{} - rr := restclient.RequestResponse{ - Url: t.Location, - Method: "DELETE", - Error: &ne, - } - status, err := t.db.Rc.Do(&rr) + resp, err := t.db.Session.Delete(t.Location, nil) if err != nil { return err } - if status != 200 { + if resp.Status() != 200 { + ne := NeoError{} + resp.Unmarshal(&ne) return ne } return nil // Success From 23e2124ce6301adadb9b2d8657078e1d0fdd42cf Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Wed, 25 Sep 2013 19:12:09 -0700 Subject: [PATCH 6/7] update to simplified napping API --- cypher.go | 4 ++-- database.go | 2 +- entity.go | 14 +++++++------- legacy_index.go | 12 ++++++------ node.go | 20 ++++++++++---------- node_index.go | 4 ++-- relationship.go | 4 ++-- schema.go | 6 +++--- transaction.go | 8 ++++---- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/cypher.go b/cypher.go index faa4bb3..47b2df7 100644 --- a/cypher.go +++ b/cypher.go @@ -75,7 +75,7 @@ func (db *Database) Cypher(q *CypherQuery) error { // Result: &cRes // Error: ne // } - resp, err := db.Session.Post(url, &payload, &result, nil) + resp, err := db.Session.Post(url, &payload, &result) if err != nil { return err } @@ -124,7 +124,7 @@ func (db *Database) CypherBatch(qs []*CypherQuery) error { res := []batchCypherResponse{} ne := NeoError{} url := db.HrefBatch - resp, err := db.Session.Post(url, payload, &res, nil) + resp, err := db.Session.Post(url, payload, &res) if err != nil { return err } diff --git a/database.go b/database.go index 536f7a9..f00de58 100644 --- a/database.go +++ b/database.go @@ -42,7 +42,7 @@ func Connect(uri string) (*Database, error) { // Method: "GET", // Result: &db, // Error: &e, - resp, err := db.Session.Get(db.Url, nil, &db, nil) + resp, err := db.Session.Get(db.Url, nil, &db) if err != nil { return nil, err } diff --git a/entity.go b/entity.go index 4096b69..04732a1 100644 --- a/entity.go +++ b/entity.go @@ -22,7 +22,7 @@ type entity struct { func (e *entity) SetProperty(key string, value string) error { parts := []string{e.HrefProperties, key} url := strings.Join(parts, "/") - resp, err := e.Db.Session.Put(url, &value, nil, nil) + resp, err := e.Db.Session.Put(url, &value, nil) if err != nil { return err } @@ -39,7 +39,7 @@ func (e *entity) Property(key string) (string, error) { var val string parts := []string{e.HrefProperties, key} url := strings.Join(parts, "/") - resp, err := e.Db.Session.Get(url, nil, &val, nil) + resp, err := e.Db.Session.Get(url, nil, &val) if err != nil { logPretty(err) return val, err @@ -60,7 +60,7 @@ func (e *entity) Property(key string) (string, error) { func (e *entity) DeleteProperty(key string) error { parts := []string{e.HrefProperties, key} url := strings.Join(parts, "/") - resp, err := e.Db.Session.Delete(url, nil) + resp, err := e.Db.Session.Delete(url) if err != nil { return err } @@ -78,7 +78,7 @@ func (e *entity) DeleteProperty(key string) error { // Delete removes the object from the DB. func (e *entity) Delete() error { - resp, err := e.Db.Session.Delete(e.HrefSelf, nil) + resp, err := e.Db.Session.Delete(e.HrefSelf) if err != nil { return err } @@ -101,7 +101,7 @@ func (e *entity) Delete() error { // Properties fetches all properties func (e *entity) Properties() (Props, error) { props := Props{} - resp, err := e.Db.Session.Get(e.HrefProperties, nil, &props, nil) + resp, err := e.Db.Session.Get(e.HrefProperties, nil, &props) if err != nil { return props, err } @@ -114,7 +114,7 @@ func (e *entity) Properties() (Props, error) { // SetProperties updates all properties, overwriting any existing properties. func (e *entity) SetProperties(p Props) error { - resp, err := e.Db.Session.Put(e.HrefProperties, &p, nil, nil) + resp, err := e.Db.Session.Put(e.HrefProperties, &p, nil) if err != nil { return err } @@ -129,7 +129,7 @@ func (e *entity) SetProperties(p Props) error { // DeleteProperties deletes all properties. func (e *entity) DeleteProperties() error { - resp, err := e.Db.Session.Delete(e.HrefProperties, nil) + resp, err := e.Db.Session.Delete(e.HrefProperties) if err != nil { return err } diff --git a/legacy_index.go b/legacy_index.go index a7c5205..cc7c03b 100644 --- a/legacy_index.go +++ b/legacy_index.go @@ -31,7 +31,7 @@ func (db *Database) createIndex(href, name, idxType, provider string) (*index, e payload.Config = config } res := new(indexResponse) - resp, err := db.Session.Post(href, &payload, &res, nil) + resp, err := db.Session.Post(href, &payload, &res) if err != nil { logPretty(err) return nil, err @@ -49,7 +49,7 @@ func (db *Database) createIndex(href, name, idxType, provider string) (*index, e func (db *Database) indexes(href string) ([]*index, error) { res := map[string]indexResponse{} nis := []*index{} - resp, err := db.Session.Get(href, nil, &res, nil) + resp, err := db.Session.Get(href, nil, &res) if err != nil { return nis, err } @@ -80,7 +80,7 @@ func (db *Database) index(href, name string) (*index, error) { if err != nil { return idx, err } - resp, err := db.Session.Get(u.String(), nil, nil, nil) + resp, err := db.Session.Get(u.String(), nil, nil) if err != nil { return nil, err } @@ -137,7 +137,7 @@ func (idx *index) Delete() error { if err != nil { return err } - resp, err := idx.db.Session.Delete(uri, nil) + resp, err := idx.db.Session.Delete(uri) if err != nil { return err } @@ -166,7 +166,7 @@ func (idx *index) add(e entity, key string, value interface{}) error { Key: key, Value: value, } - resp, err := idx.db.Session.Post(uri, &payload, nil, nil) + resp, err := idx.db.Session.Post(uri, &payload, nil) if err != nil { return err } @@ -192,7 +192,7 @@ func (idx *index) remove(e entity, id, key, value string) error { uri = join(uri, key, value) } uri = join(uri, id) - resp, err := idx.db.Session.Delete(uri, nil) + resp, err := idx.db.Session.Delete(uri) if err != nil { return err } diff --git a/node.go b/node.go index e28a502..fd06dfa 100644 --- a/node.go +++ b/node.go @@ -13,7 +13,7 @@ import ( func (db *Database) CreateNode(p Props) (*Node, error) { n := Node{} n.Db = db - resp, err := db.Session.Post(db.HrefNode, &p, &n, nil) + resp, err := db.Session.Post(db.HrefNode, &p, &n) if err != nil || resp.Status() != 201 { logPretty(resp.Status()) ne := NeoError{} @@ -34,7 +34,7 @@ func (db *Database) Node(id int) (*Node, error) { func (db *Database) getNodeByUri(uri string) (*Node, error) { n := Node{} n.Db = db - resp, err := db.Session.Get(uri, nil, &n, nil) + resp, err := db.Session.Get(uri, nil, &n) if err != nil { return nil, err } @@ -89,7 +89,7 @@ func (n *Node) getRels(uri string, types ...string) (Rels, error) { uri = strings.Join(parts, "/") } rels := Rels{} - resp, err := n.Db.Session.Get(uri, nil, &rels, nil) + resp, err := n.Db.Session.Get(uri, nil, &rels) if err != nil { return rels, err } @@ -132,7 +132,7 @@ func (n *Node) Relate(relType string, destId int, p Props) (*Relationship, error if p != nil { content["data"] = &p } - resp, err := n.Db.Session.Post(srcUri, content, &rel, nil) + resp, err := n.Db.Session.Post(srcUri, content, &rel) if err != nil { return &rel, err } @@ -147,7 +147,7 @@ func (n *Node) Relate(relType string, destId int, p Props) (*Relationship, error // AddLabels adds one or more labels to a node. func (n *Node) AddLabel(labels ...string) error { - resp, err := n.Db.Session.Post(n.HrefLabels, labels, nil, nil) + resp, err := n.Db.Session.Post(n.HrefLabels, labels, nil) if err != nil { return err } @@ -165,7 +165,7 @@ func (n *Node) AddLabel(labels ...string) error { // Labels lists labels for a node. func (n *Node) Labels() ([]string, error) { res := []string{} - resp, err := n.Db.Session.Get(n.HrefLabels, nil, &res, nil) + resp, err := n.Db.Session.Get(n.HrefLabels, nil, &res) if err != nil { return res, err } @@ -183,7 +183,7 @@ func (n *Node) Labels() ([]string, error) { // RemoveLabel removes a label from a node. func (n *Node) RemoveLabel(label string) error { uri := join(n.HrefLabels, label) - resp, err := n.Db.Session.Delete(uri, nil) + resp, err := n.Db.Session.Delete(uri) if err != nil { return err } @@ -201,7 +201,7 @@ func (n *Node) RemoveLabel(label string) error { // SetLabels removes any labels currently on a node, and replaces them with the // labels provided as argument. func (n *Node) SetLabels(labels []string) error { - resp, err := n.Db.Session.Put(n.HrefLabels, labels, nil, nil) + resp, err := n.Db.Session.Put(n.HrefLabels, labels, nil) if err != nil { return err } @@ -220,7 +220,7 @@ func (n *Node) SetLabels(labels []string) error { func (db *Database) NodesByLabel(label string) ([]*Node, error) { uri := join(db.Url, "label", label, "nodes") res := []*Node{} - resp, err := db.Session.Get(uri, nil, &res, nil) + resp, err := db.Session.Get(uri, nil, &res) if err != nil { return res, err } @@ -242,7 +242,7 @@ func (db *Database) NodesByLabel(label string) ([]*Node, error) { func (db *Database) Labels() ([]string, error) { uri := join(db.Url, "labels") labels := []string{} - resp, err := db.Session.Get(uri, nil, &labels, nil) + resp, err := db.Session.Get(uri, nil, &labels) if err != nil { return labels, err } diff --git a/node_index.go b/node_index.go index 872d0d6..8f5be8b 100644 --- a/node_index.go +++ b/node_index.go @@ -72,7 +72,7 @@ func (idx *LegacyNodeIndex) Find(key, value string) (map[int]*Node, error) { return nm, err } result := []Node{} - resp, err := idx.db.Session.Get(u.String(), nil, &result, nil) + resp, err := idx.db.Session.Get(u.String(), nil, &result) if err != nil { return nm, err } @@ -104,7 +104,7 @@ func (idx *index) Query(query string) (map[int]*Node, error) { return nm, err } result := []Node{} - resp, err := idx.db.Session.Get(u.String(), nil, &result, nil) + resp, err := idx.db.Session.Get(u.String(), nil, &result) if err != nil { return nm, err } diff --git a/relationship.go b/relationship.go index 68a9a7e..dd7cf91 100644 --- a/relationship.go +++ b/relationship.go @@ -15,7 +15,7 @@ func (db *Database) Relationship(id int) (*Relationship, error) { rel := Relationship{} rel.Db = db uri := join(db.Url, "relationship", strconv.Itoa(id)) - resp, err := db.Session.Get(uri, nil, &rel, nil) + resp, err := db.Session.Get(uri, nil, &rel) if err != nil { return &rel, err } @@ -36,7 +36,7 @@ func (db *Database) Relationship(id int) (*Relationship, error) { // Types lists all existing relationship types func (db *Database) RelTypes() ([]string, error) { reltypes := []string{} - resp, err := db.Session.Get(db.HrefRelTypes, nil, &reltypes, nil) + resp, err := db.Session.Get(db.HrefRelTypes, nil, &reltypes) if err != nil { return reltypes, err } diff --git a/schema.go b/schema.go index 270b19a..c550674 100644 --- a/schema.go +++ b/schema.go @@ -18,7 +18,7 @@ type Index struct { // Drop removes the index. func (idx *Index) Drop() error { uri := join(idx.db.Url, "schema/index", idx.Label, idx.PropertyKeys[0]) - resp, err := idx.db.Session.Delete(uri, nil) + resp, err := idx.db.Session.Delete(uri) if err != nil { return err } @@ -39,7 +39,7 @@ func (db *Database) CreateIndex(label, property string) (*Index, error) { uri := join(db.Url, "schema/index", label) payload := indexRequest{[]string{property}} result := Index{db: db} - resp, err := db.Session.Post(uri, payload, &result, nil) + resp, err := db.Session.Post(uri, payload, &result) if err != nil { return nil, err } @@ -58,7 +58,7 @@ func (db *Database) CreateIndex(label, property string) (*Index, error) { func (db *Database) Indexes(label string) ([]*Index, error) { uri := join(db.Url, "schema/index", label) result := []*Index{} - resp, err := db.Session.Get(uri, nil, &result, nil) + resp, err := db.Session.Get(uri, nil, &result) if err != nil { return result, err } diff --git a/transaction.go b/transaction.go index 77114f8..720605f 100644 --- a/transaction.go +++ b/transaction.go @@ -63,7 +63,7 @@ func (tr *txResponse) unmarshal(qs []*CypherQuery) error { func (db *Database) Begin(qs []*CypherQuery) (*Tx, error) { payload := txRequest{Statements: qs} result := txResponse{} - resp, err := db.Session.Post(db.HrefTransaction, payload, &result, nil) + resp, err := db.Session.Post(db.HrefTransaction, payload, &result) if err != nil { return nil, err } @@ -94,7 +94,7 @@ func (t *Tx) Commit() error { if len(t.Errors) > 0 { return TxQueryError } - resp, err := t.db.Session.Post(t.hrefCommit, nil, nil, nil) + resp, err := t.db.Session.Post(t.hrefCommit, nil, nil) if err != nil { return err } @@ -110,7 +110,7 @@ func (t *Tx) Commit() error { func (t *Tx) Query(qs []*CypherQuery) error { payload := txRequest{Statements: qs} result := txResponse{} - resp, err := t.db.Session.Post(t.Location, payload, &result, nil) + resp, err := t.db.Session.Post(t.Location, payload, &result) if err != nil { return err } @@ -136,7 +136,7 @@ func (t *Tx) Query(qs []*CypherQuery) error { // Rollback rolls back an open transaction. func (t *Tx) Rollback() error { - resp, err := t.db.Session.Delete(t.Location, nil) + resp, err := t.db.Session.Delete(t.Location) if err != nil { return err } From c886a2d3342079cf2fb662bc6707e852ec6e608f Mon Sep 17 00:00:00 2001 From: Jason McVetta Date: Thu, 26 Sep 2013 13:20:05 -0700 Subject: [PATCH 7/7] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d9f540..621add4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ neoism - Neo4j client for Go =========================== -![Neo4j + Gopher Logo](https://raw.github.com/jmcvetta/neoism/master/neoism.png) +![Neoism Logo](https://raw.github.com/jmcvetta/neoism/master/neoism.png) Package `neoism` is a [Go](http://golang.org) client library providing access to the [Neo4j](http://www.neo4j.org) graph database via its REST API.