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.
begininsert into public.hosts (data)return idend
begininsert into public.hosts (data)return idend
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.
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.