Sorting by distance

Hi, I am stuck with this, please help me out. I want to fetch data based on users location. I am using prisma. I have one prisma query where i have applied all sorts or filter and search, which would be a nightmare if i were to do it in raw query. but now that i want data by location i want to run this query and get data on the ordered by distance table. How should i use it with first query. because this query cannot be run with prisma query.

prisma.$queryRaw`SELECT id,
(6371 * acos(cos(radians(${lat}))
* cos(radians(lat))
* cos(radians(lng) - radians(${lng}))
+ sin(radians(${lng}))
* sin(radians(lat)))) AS distance
FROM venues
ORDER BY distance;`

prisma.$queryRaw`SELECT id,
(6371 * acos(cos(radians(${lat}))
* cos(radians(lat))
* cos(radians(lng) - radians(${lng}))
+ sin(radians(${lng}))
* sin(radians(lat)))) AS distance
FROM venues
ORDER BY distance;`
0 Replies
No replies yetBe the first to reply to this messageJoin