Replies: 1 comment
-
Hi @chiefGui! I happen to be in love with Supabase too! Question 1You can set a row level security policy to make sure that whenever a data is inserted or updated in your profiles table, the For example, you can create a policy like this to make sure that a user can only insert their own profile on row where create policy "Profiles can only be inserted by themselves"
on profiles for insert
with check ( auth.uid() = id ); Question 2Since create policy "Users can only read posts if they have a profile setup"
on posts
for select using (
case
when exists (
select * from profiles
where id = auth.uid()
) then true
else false
end
); Question 3In order to trigger a function, you can just simply edit the target row from within the table editor of Supabase. This should be much faster than executing a code from your app. Also, if you are receiving webhooks from Supabase and you want to test that, you can use Webhook.site to easily receive a webhook! |
Beta Was this translation helpful? Give feedback.
-
Hey guys! In love with Supabase. ❤️
When a user signs up in my app, they must create a profile. This process requires them to enter a
displayName
.That said, I have a few questions:
Question 1: Insert using
uid
How can I insert into a table using a user's id? The one at
auth
/jwt
? I know I can create this policy withupdate
operations, but unsure how to do that for inserts. 🤔 In other words, whenINSERT
ing intoprofiles
, I want to (automatically) fill theid
column of my new row with the one Postgres is already aware of through the JWT that is passed to it when the user makes the request.The reason I'm asking this is that I don't want to allow people to create profiles for other people that may happen to don't have a profile.
Question 2: Custom "
authenticated
" equivalent policyHow do I create a policy that only allows people to do operations (such as
select
,insert
, etc.) if they have adisplayName
which is notnull
?The reason I'm asking this is that I want to limit what a user without a profile can do within my app.
Question 3: Workflow for functions & triggers
This one is pretty straightforward: how do you test (Postgres) functions and triggers at Supabase?
I am a complete noob when it comes to
psql
/pgsql
/etc, and when writing Postgres functions, triggers, and general code using its language, it takes a great amount of time for me to debug, iterate, tweak and refactor. In short, my process looks like: I write the code completely blind, go to my app and send a request (using supabase-js) to my API and see what happens. That's slow. I'd like to know how YOU do it. (This would come in handy!)I guess that's it for now. Sorry if my questions lack some clarity, but at this point, that's all I got. Take care yourselves, yes?
Disclaimers
Beta Was this translation helpful? Give feedback.
All reactions