https://supabase.com/ logo
Hello guys, I want to add some extra info into my ...
# help
h
Hello guys, I want to add some extra info into my profiles table on user signup, I have set up the trigger functions, but I don't know how to add those fields in UI, so I am using Next Js and supabase javascript package but no resource showing the exact implementation of this on frontend side. And this below is not clear enough!!!
n
Hello @Hussein Kizz! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g
What ever you put in the data object will be added to auth.users raw_user_meta_data column as json. You should be able to see it using the dashboard table UI after a user is signed up. Your trigger function would then insert that data into your profile table.
h
Thank you, however, that I know but are the same fields I'd be referring to as the new object in my trigger function?
g
Yes new.raw_user_meta_data->>'name'
Or just new.raw_user_meta_data if you want to copy the whole json object.
h
For example, l currently have the following function and I want these additional fields such as user_name, user_email, user_contact, user_avatar_url. my current function: begin insert into public.profiles(id) values(new.id); return new; end;
It really creates the new user profile row on every signup but no these fields, thanks
g
You have to have columns in your profile row like last_name (if you had a last_name object submitted with data object). Then you would
Copy code
insert into public.profiles(id,last_name)     //last_name is the col name in profile table
values(new.id, new.raw_user_meta_data->>last_name.
You can search top left for raw_user_meta_data and you will find examples.
Or maybe supabase github discussions for examples
h
Oh yes, I have those columns in there already, let me try on that, thanks I will let you know if it works, otherwise I also had tried another approach where I just create the user profile row using trigger and then immediately update the columns after each signup and it was working with 1 or 2 quirks but now let me try that approach you have taught me, thanks!
g
OK I'm out for the night.
h
Hello, thanks things worked as expected, I set up the trigger and function and it worked except that I didn't want to include the user avatar right away before a user is created in the DB, so I intended to only upload the avatar after a user is created in DB and then update their avatar_url column in profile table with the new uploaded avatar url.
and it uploads to the bucket but am failing to get its URL into the profiles table, I wonder what I could be doing wrong down here:
My DB, avatar url column remains null, even the console.log of the code above is not called, is there any error in my syntax or what?
Thank you so much, am sorry if it's too much of help!
2 Views