That's what I was guessing, but it's not super cle...
# javascript
x
That's what I was guessing, but it's not super clear in the doc. How do I do that?
g
Does your table have a primary key?
Normally for what you are doing you would use the uuid of the user.
x
So i need to set the uuid of the user as a primary key, pass it in my upsert value and it should do the trick?
g
What is your primary key in the table?
Oh, maybe that is what you meant you need to do... yes
x
Here is my table
The id is autogenerated
g
You don't really need id.
In fact you would have to provide id in the upsert too if you have it.
Which would be hard unless you keep track of it.
x
Yeah, that means that I would need to select first to get the id and then upsert
which makes no sense
g
uuid alone is a good primary key.... assuming you don't already have duplicates in the table, then you would have to clean them up.
In fact the docs warn about using a surrogate (incrementing) key with upsert I think not just because of the fetch, but by auto increment nature they would never match...
x
Yes Gary, now it seems obvious but it's hard to understand it from the doc…
Anyways, thanks! it works now
g
Hey I just had to go google surrogate key... lol
x
Maybe we can update the doc?
g
Yeah it would be more clear if it said (like an auto-incrementing key).
x
Is there a github repo I could fork and make a PR?
g
It is a bit of a learning process (at least it was for me doing a few doc updates awhile back). It is supabase/supabase github to generate a doc issue. The doc repo is embedded in that.