https://supabase.com/ logo
When you create a teams table, does the user_id sh...
# help
r
When you create a teams table, does the user_id should be an array ?
n
Hello @React noob! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! 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.
g
You could do that, or you could create a table with userid and teamid columns and have a row for each pair including users on multiple teams. Either don’t have either a PK, add a inc primary key, or combine both columns as a unique primary key depending on how you use it. You then use this table to find members of a team or what teams a user belongs to.
r
But how can i add someone in a team via the joins table ?
g
You just insert the uid/team_id pair into the table... I have a chat room table (you can envision chatroom as a team). My table looks like: You can see in the last two lines two users belong to the same room. I also have an owner flag of the room. The primary id column in this case is not used, so I probably should get rid of it at some point.
r
so you do not not create a colum in user like room_joins_id: id ?
g
No. I did not want to deal with array updates and searches.
I just select with the uid from the room_joins table to get their rooms.
You can also use a select with id on user table and have join done if you make uid an fk to user table.
r
Thank you
other sujet question i want to be the only person allowed to post things
this is how we do ?
in user i have a admin column
how can i configure the policies to say only user with role admin can insert row ?
g
You really should start a new thread for a different type question, no guarantee anyone else will look after there are a number of posts, and I may or not be here to see it. I'm not clear on what you are asking in the first one. You as supabase_admin (in dashboard)? If so just put RLS insert and update to false. Then only can be updated from the dashboard. This page should give ideas on the 2nd question: https://supabase.com/docs/guides/auth/row-level-security#policies-with-joins Or search here, the web for Postgrest (SB is just Postgres with auth and storage), or even SB discussions.
r
ok ty
n
Thread was archived by @React noob. Anyone can send a message to unarchive it.