gremgo
gremgo copied to clipboard
Request: return struct instead of interface{}
For example the function: ExecuteStruct(...)
= same as Execute(...)
but a result as a struct rather than an interface.
Reason for request: sometimes the structure is known and this makes it easier to handle.
Full example:
type Edges [][]struct {
ID int `json:"id"`
InV int `json:"inV"`
InVLabel string `json:"inVLabel"`
Label string `json:"label"`
OutV int `json:"outV"`
OutVLabel string `json:"outVLabel"`
Properties struct {
LocationURL string `json:"locationUrl"`
Type string `json:"type"`
} `json:"properties"`
Type string `json:"type"`
}
var edges *Edges
err := f.client.ExecuteStruct(
"SOME-TINKERPOP-QUERY",
&edges,
map[string]string{"uuid": UUID.String()},
map[string]string{},
)
I think returning a []][]byte
, where each element contains a byte slice containing the JSON result for the request, would also be nice. The thing it does now with returning an interface{}
makes the library a pain in the ass to use. Users should be able to unmarshal the response however they way.
Sure, same solution from a different angle.