Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: return struct instead of interface{} #42

Open
bobvanluijt opened this issue Jul 6, 2018 · 2 comments
Open

Request: return struct instead of interface{} #42

bobvanluijt opened this issue Jul 6, 2018 · 2 comments

Comments

@bobvanluijt
Copy link

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{},
	)

@bobvanluijt bobvanluijt changed the title Request to return struct instead of interface{} Request: return struct instead of interface{} Jul 6, 2018
@slnt
Copy link

slnt commented Oct 11, 2018

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.

@bobvanluijt
Copy link
Author

Sure, same solution from a different angle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants