Hello, How can I prevent an user from inserting mu...
# help
a
Hello, How can I prevent an user from inserting multiple rows in a table ?
n
Hello @abc222! 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.
o
Hi you can use policies to restrict the access depending on conditions @abc222
n
abc222 (2022-05-12)
a
Do you have an example policy that lets only insert one row ?
I searched but can't find something that would do that
o
You can simply check if ``auth.user().uuid`` is already in the table. Unfortunately, I'm not really good at Postgres, so i can't drop you a real world example 😅
a
Is an insert policy working row by row even when an INSERT inserts multiple row ? that would be great but i'm not so sure Btw yea, Supabase has a very good JS SDK documentation, but documentation about PostgreSQL possibilities, like triggers etc, is pretty lacking, it needs much more documentation to show us how to do specific things with Postgre, since Postgre's documentation itself isn't very clear
o
Actually there is no docs about that because there are already a docs, and the official Postgres docs isn't that bad
a
They don't provide example on specific case, so it's hard to understand exactly what to do securely Since it's a security concern, I think it's important to document it as much as possible
m
What do you mean by “prevent a user from inserting multiple rows in a table” Like do you mean like, just ONE row per table per user? Or do you mean, prevent multiple rows from being inserted per statement/transaction? - also the Postgres docs are REALLY thorough, but it takes time to understand it. Backend docs like PostgreSQL are a lot more technical and is a learning curve to understand than like say front end docs (like react)