Hey, amazing updates during the launch week 4. Rea...
# sql
d
Hey, amazing updates during the launch week 4. Really exciting where Supabase is going! I have a small question regarding the RLS for my use case. I have a table
countries
where each
country
has a
people
array of uuid. Every
county
can have multiple
cities
where each
city
has one
county_id
. I want to giver CRUD access to
cities
for the
people
. How can I set it up using the RLS? UPD: Added a SQL diagram in the thread.
Not sure if countries - people relation is correctly drawn. It's so, that countries can have many people and one person can be a part of multiple countries
I was thinking maybe something like
Copy code
create policy "People can all on own cities" 
  on cities for all
  using (auth.uid() = any (
    select people
    from counties
    where (country_id = id)
  ))
But it gives
operator does not exist: uuid = uuid[]
t
try to use unnest the array
Copy code
sql
  select unnest(people)
    from counties
d
Thanks a lot, it worked!
t
No worries