Shared Data Example

Hello,

I'm coming over from Firebase and haven't worked with Data Models like this in a while (Or RLS at all really).

I'm trying to make a contrived example of sharing data between users to better understand how to model a real world project.

So imagine I have Users: A, B, C. and a another table Blogs

User A creates Blog X

User A invites User B to able to SELECT/UPDATE to Blog X
and invites User C to only be able to SELECT from Blog X

---

Is this something that I would handle with RLS? Does anyone have any examples that could get me going in a direction? I've read through auth policies but most examples like this one seem to be somewhat static (the email @blizzard isn't something one user could assign/share to another)

I'm guessing I may need to add a new role? But I'm not sure how to do that on a many-to-many relationship. i.e. Many users will have different access to many blogs.

Also, to reiterate, Blogs is just a contrived example. Imagine this scenario with anything. Chat rooms, Trello cards, Google Docs, etc...
Supabase Auth Deep Dive Part 3: User Based Access Policies
Was this page helpful?