Supabase Postgress Function Search Pagination

Hi guys,

I have a Postgress function that I am calling from WeWeb. I would like to add the pagination, but can’t really figure it out.

These are my param:

I get this back:

In the Custom Paginator, I liked the total records called, but not sure if I need to bind the offset here or bind it in the new function call on change.

Thanks,

If you are passing the offset, then you need to bind it to be result_limit * (current_page - 1) if the pages start from 1. I’d probably just change your function to accept result_limit and page and then do this math on the backend for a cleaner workflow. I also thin you’ll need to return the current page and total_count, as you’re already doing.

The way I’ve done pagination in Postgres Functions are like what Broberto has said. You want to have the parameters as Page Number and Page Size (result_limit in your case), then you can do the equation that Broberto said in your function, result_limit * (current_page - 1).

Definitely don’t have to return the current page if you don’t want and keep that logic on the front end but that does add extra stuff to the front end, but this also depends on what kind of UI/UX you want for your pagination. I’ve created a global formula to will an array of Pages with “Page ” which takes the total count of the results and the current result limit to give me an array to use for selecting a certain page if thats the kind of UX you want.

I think I did something similar. It is working now.