supabase-community / postgrest-go

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

Update doesn't work #26

Closed billypap1 closed 2 years ago

billypap1 commented 2 years ago

Hello, i use this library in order to perform operations to my Supabase database. I have connected to db with the client:

var (
    headers = map[string]string{"Authorization": fmt.Sprintf("Bearer %s", tokenApi), "apikey": tokenApi}
)

client := postgrest.NewClient("https://<projectID>.supabase.co/rest/v1/", "public", headers)

And I update the table like this:

info, count, err := client.From("testTable").Update(map[string]string{"state": "offline"}, "", "").Match(map[string]string{"member": "comid"}).ExecuteString()
fmt.Println(info) ->  [{"id":1,"member":"comid","avatar":"asdasd","state":"offline"}] 
fmt.Println(count)
fmt.Println(err)

I'm not getting any error and it returns the response in string, but the column "state" in db doesn't update to "offline".

billypap1 commented 2 years ago

Fixed it, my mistake, wrong api key