https://supabase.com/ logo
#help
Title
# help
b

Bryan K.

03/25/2022, 10:02 PM
Anyone have advice on the best setup for multiple authenticated users having access to the same row when using RLS on a table? Do you just store an array of UUIDs in the record and then test to see if the array contains the UUID on request?
n

Needle

03/25/2022, 10:02 PM
Hello ! This thread has been automatically created from your message in a ``few seconds ago``. Pinging @User so that they see this as well! 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.
b

Bryan K.

03/25/2022, 10:04 PM
There are lots of examples of 1:1, row:uuid security, but I haven't found one for 1:n row:uuids.
g

garyaustin

03/25/2022, 10:05 PM
You could use an array, or I like to use a "member" table that is just pairs of member id's with the id of the thing they have access to. For me that is chat rooms (which are a row).
n

Needle

03/25/2022, 10:05 PM
Bryan K. (2022-03-25)
b

Bryan K.

03/25/2022, 10:06 PM
Do you enable RLS for the table and then handle the check for the data table in a Supabase DB Function?
g

garyaustin

03/25/2022, 10:07 PM
The RLS would look up in the member table for a uid match with the row id.
b

Bryan K.

03/25/2022, 10:09 PM
I see, then return the results from the 'rooms' table that the member table pairs the UUID with.
b

Bryan K.

03/25/2022, 10:09 PM
@User this is perfect thank you!
n

Needle

03/25/2022, 10:12 PM
Thread was archived by @Bryan K.. Anyone can send a message to unarchive it.