In supabase Javascript client is it possible to do a distance filter? If possible, I'd like to avoid implementing server-side logic.
// Define the distance threshold in meters (50km = 50000m)
const distanceThreshold = 50000
const targetLatitude = 10.724577
const targetLongitude = 5.525625
const supabaseClient = createClient(supabaseUrl, supabaseKey)
supabaseClient
.from('my_table')
.select('*')
.filter(
`ST_Distance_Sphere(
ST_MakePoint(longitude, latitude),
ST_MakePoint(${targetLongitude}, ${targetLatitude})
)`, 'lt', distanceThreshold
)
.then(console.log)
I want to get the records from the table "my_table" at a maximum distance of 50km from the target position position, is it possible to do something like this?