I have a related question. I have an update prof...
# help
j
I have a related question. I have an update profile page where I do an upsert, but because my profile id is generated automatically by supabase- my upsert won’t work. The upsert requires sending primary key on payload , but if it’s the first time a profile os created, I won’t have a primary key Do I need to generate my keys on the client?
s
If you're using SQL to insert or update the record (e.g. a Postgres function), you can use the
RETURNING
keyword to get data back from the query. Example: https://stackoverflow.com/questions/6560447/can-i-use-return-value-of-insert-returning-in-another-insert Another example: https://lornajane.net/posts/2016/the-returning-keyword-in-postgresql Docs: https://www.postgresql.org/docs/9.5/sql-insert.html I'm not sure how you'd write that if you're using the library to upsert the data
j
Thank you @User - i'll have a look at this.
Thinking I might just use a conditional with two different updates/creates