Hey everyone, I have a reservation app, let's just...
# help
e
Hey everyone, I have a reservation app, let's just call it airbnb since the functionality is similar. I need to show available listings (listings without reservations during the time period the user selects: start date - end date). I have a sql script that'll return the available listings, but how can I call that via the api? Should I use a stored procedure? A view doesn't work because I'd have to create one for every query
s
Yes a function would work in this case and you call it via the
.rpc
method https://supabase.io/docs/reference/javascript/rpc
e
What's the process for this? Create the remote procedure then call it via API?
for reference, I'm not using JS
only the api
s
Oh, not sure what the call looks like for the API, but you could use JS and then see what url is being called
e
okay, are there any docs for creating .rpc?
or is it always calling .rpc w/ the parameters?
s
Not sure what you mean, a rpc is just a Postgres function
This is up to you the developer, I mean if you don't need parameters then I would like to think a view would suffice.
e
I have two pieces: the sql script that returns the available listings and the user's start_date end_date. I'll always pass the start_date & end_date w/ each call. but where does the available_listings script go?
s
You write it in a Postgres Function
I'm curious as to why you are calling the API endpoints directly instead of using one of the client libraries?
e
we build mobile apps for clients on adalo
can only call via API.
there are several devs using supabase x adalo. Usually it's pretty easy but this is a unique scenario where we can't filter or select since we need to see how the inverse of the reservation table (availability)
Also, password changing is a problem if you remember that convo awhile ago.
s
Yeah I remember that convo
e
we have to build a web app to do that
s
I should take a look into Adalo one day, so many new awesome tech out there now
e
yeah, absolutely. it's probably the easiest "no code" app builder. Very intuitive & easy
thanks for this. will try and work through these docs and see if we can get it working
s
Ok no problem