Hey guys, I am doing a policy to prevent a user from "double" booking a listing, and I am wondering if the following WITH CHECK is valid or if it's efficient.
Conditions = Check if the authenticated user
reserved_by
reserved_by
already booked the existing
listing_id
listing_id
WITH CHECK (auth.uid() = reserved_by AND NOT EXISTS ( select 1 from reservations where listing_created_by = listing_created_by));
WITH CHECK (auth.uid() = reserved_by AND NOT EXISTS ( select 1 from reservations where listing_created_by = listing_created_by));
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.