Skip to content

Generate ID on client before insert? #920

Discussion options

You must be logged in to vote

Hey @tommyc38,

You'll need a SQL function for this, but the implementation depends on the type of ID you use.

For example if it's an UUID, you could do:

create or replace function gen_id() returns uuid as $$
  select extensions.uuid_generate_v4();
$$ language sql;

Then to get it on the frontend

const { id, error } = await supabase
  .rpc('gen_id')

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@tommyc38
Comment options

@tommyc38
Comment options

@steve-chavez
Comment options

Answer selected by tommyc38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants