supabase-community / postgrest-go

Isomorphic Go client for PostgREST. (Now Updating)
https://supabase.io
Apache License 2.0
170 stars 27 forks source link

New execute method for json objects #10

Closed aaronschweig closed 3 years ago

aaronschweig commented 3 years ago

What kind of change does this PR introduce?

This PR implements a new executeTo method which automatically parses the response into a json object as described in #7

What is the current behavior?

7

What is the new behavior?

An ExecuteTo method was added to the structs as described which directly parses the response body into an interface{}

Additional context

I tried to implement the changes described in the issue but was not sure regarding the requriements. I currently implemented the functions as requested with the return value of an (interface{}, error) for the ExecuteTo functions.

I also thought about changing the function to ExecuteTo(target interface{}) error which enables the user to give a custom struct or map from outside. Then instead of creating a new object inside the executeTo function, this target value is used to parse the response body into. I would be open to implement this function as well - maybe under a different name like ExecuteInto

As this is my first contribution, i hope i didn't miss something or did something wrong, if so please let me know so i can fix it!

yusufpapurcu commented 3 years ago

Actually I mis explained problem a little 😅 We need exactly ExecuteInto. Can you implement this named as ExecuteTo ?

Great work and thanks for support 👍

aaronschweig commented 3 years ago

Okay, maybe i just misunderstood the issue 😃

I pushed the changes with the needed functionality 😄

yusufpapurcu commented 3 years ago

Great work thanks for support 💯