RPC anon insert return ID
Hello,
In this project I'm using anonymous insert of data from the front-end (next.js) into supabase postgres. The problem with this is that I also need to return the auto incremented ID for the data to the anonymous user. For this to be possible with RLS I guess I need to make read available to anyone, which is a no no. It's bad enough that insert will be open to anyone.
As I understand it, I need to use RPC for this. The problem is that I don't really know how to think about the logic.
I created a database function and I guess it needs to start with something like this.
How do I make the logics here so that the id from the newly created row is returned? Thanks everyone. I'm slow but I'm learning.
In this project I'm using anonymous insert of data from the front-end (next.js) into supabase postgres. The problem with this is that I also need to return the auto incremented ID for the data to the anonymous user. For this to be possible with RLS I guess I need to make read available to anyone, which is a no no. It's bad enough that insert will be open to anyone.
As I understand it, I need to use RPC for this. The problem is that I don't really know how to think about the logic.
I created a database function and I guess it needs to start with something like this.
How do I make the logics here so that the id from the newly created row is returned? Thanks everyone. I'm slow but I'm learning.