From the course: Supabase Essential Training
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Calling functions through RPC
From the course: Supabase Essential Training
Calling functions through RPC
- [Instructor] In Supabase, custom PostgreSQL functions can be used as remote procedure calls. Every function added to the public schema becomes a potential RPC endpoint. Let's take a look at an existing database function in the public schema and call it via RPC. So the existing function that we're going to look at is purchased from gift card. We just go over here to edit function, and it brings that function up. We have two arguments for this function, one for the user ID and one for the amount of the purchase. And then we have the function itself. This starts with variable declaration. I just have one variable here for the new balance. So that gets declared up here. And then this is the body of the function. So in this function, we are updating the gift cards table. This gift cards table has a balance cents column, and we're going to set that to the value that it was before, only removing the amount that we are using…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.