Skip to main content
adding new tags make better reach of this question
Link
Source Link

How to use Supabase DB Functions in Javascript Client API using Select Query?

My Goal is to get the coordinates in human readable form without using a seperate request as follows.

supabase.rpc('fn')

I have a table named live_route and it is linked to an other table named profile. I want to get the data of profile and live_route. Table Relations are Profile => Shifts => Locations => Live_route

From below Code You will understand the relations more clearly and how I want to run the function.

   const { data, error } = await supabase
.from('profiles')
.select(`
      id,
      first_name,
      last_name,
      status,
      role,
      profile_image_url,
      phone,
      created_at,
      rating,
      experience,
      user_id,
      email,
      availability,
      last_sign_in_at,
      shifts (
      *,
        location:locations (
          *
        ),
        live_location: live_route(
        coordinates,
        lng_lat: lng_lat_conversion(coordinates)
        )
      ),
      ...organizations(
        organization_name: name
      ), certificates(name)
      `)
.eq('id', id)
.single();

Currently I am getting following error

Relation between Profile and lng_lat_conversion not found.

Please guide how I can achieve my goal of sending a signle request without using rpc.