What's the best work to handle a else if statement...
# sql
t
What's the best work to handle a else if statement in a policy? This is what i'm trying...
Copy code
(if 
   auth.role() = 'authenticated'
   and 
   is_draft = false
 then
   true;
elsif
   auth.uid() = user_id 
then
   true;
else
  false;
end if;
)
Must be a better way to do it? I want to only be able to read the row if is_draft is false or it's the the user who's post it is
Any help would be appreciated 🙂
a
try
auth.uid() = user_id or (auth.role() = 'authenticated' and is_draft = false)
t
Thanks man. I knew it would be simple, just getting started on sql/postgres.