'Translating sql query to typeorm
Can someone help me translate this query to typescript typeorm query? I have tried for serval hours, but I keep getting stuck in some way or another. And my biggest question is if this even is possible with typeorm.
SELECT objects_2.date_added, objects_2.updated_at, objects_2.uuid, objects_2.price, objects_2.address, objects_2.square_meters,
ARRAY(SELECT ROW(date_added, updated_at, created_at, square_meters, uuid, price, address)
FROM (select * from objects)objects
WHERE open = true
AND uuid != objects_2.uuid
AND floor = objects_2.floor
AND latitude >= (objects_2.latitude - (0.03 * (360 / (cos(objects_2.latitude) * 40075))))
AND latitude <= (objects_2.latitude + (0.03 * (360 / (cos(objects_2.latitude) * 40075))))
AND longitude >= (objects_2.longitude - (0.03 * (360 / (cos(objects_2.longitude) * 40075))))
AND longitude <= (objects_2.longitude + (0.03 * (360 / (cos(objects_2.longitude) * 40075))))
AND CASE
WHEN object_type IN ('flat', 'commercial_space') AND objects.square_meters IS NOT NULL THEN square_meters = objects_2.square_meters
END)
AS equal_listings
FROM (SELECT * FROM objects ORDER BY date_added DESC) objects_2
WHERE objects_2.square_meters != 0
LIMIT 30
OFFSET 0;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
