https://supabase.com/ logo
#javascript
Title
# javascript
a

a d

07/29/2021, 3:47 PM
isee thanks for clarification for last point -> it's bcs i m creating a note taking type of app where users can create acc and use create different section of notes public/private and i don't know how to structure db so i can keep all the notes with their proper dates and stuffs so im creating different table for different users so db is structure nosql is different from relational db so it's hard to think in terms of column based db as i m shifting from firebase
wow what
new feature
s

Scott P

07/29/2021, 3:50 PM
So, the way I'd handle this is have the user_id stored for each note. When a user wants to create a new note, their user_id is added alongside their note. You can then use row level security (in the policies tab in the dashboard), to restrict it, something like this should do it:
(id = uid()
If there's public notes, that complicates things a little, but you could add another check to the RLS query, where it checks if
private
is true
a

a d

07/29/2021, 3:52 PM
oh isee that is lot more scalable and easier although i didn't get
id = uid()
what are we checking here ?
yeah it's doable thanks for that
omg thank you very much rls is what i needed i thought maybe policies are in development
for securing data
s

Scott P

07/29/2021, 3:57 PM
uid()
is a built in function inside Supabase. I've just checked my dashboard, and an example I have is:
(uid() = owned_by_user)
owned_by_user
is a column which includes the user ID
Only rows where
owned_by_user
is the same as
uid()
will be returned when querying data
a

a d

07/29/2021, 3:59 PM
ooh isee thanks that is lot more simpler than making table for every user
btw..
is there a limit to no of tables
s

Scott P

07/29/2021, 4:00 PM
No hard-coded limit, it's only limited by the amount of server resources (e.g. memory)
a

a d

07/29/2021, 4:00 PM
mhm alr thankyou again