aretherecookies-mobile/sample-query.sql
Bart Akeley 9221b7f9b5 quantities round trip api and stream
make POST requests to /quantity to update the quantity of an existing food item - then mixin the new quantity with the existing food items observable
2017-11-26 19:52:16 -06:00

17 lines
614 B
SQL

SELECT
f.id AS id,
f.name AS name,
f.place_id AS place_id,
f.category AS category,
f.images AS images,
f.thumbImage AS thumbImage,
ST_AsGeoJSON(f.loc) AS location,
ST_Distance(f.loc, ST_SetSRID(ST_Point(-97.7286718, 30.3033267),4326)::geography) / 1609 AS distance,
q.quantity AS quantity,
q.date AS lastUpdated
FROM food_items f
LEFT OUTER JOIN latest_quantities q
ON f.id = q.food_item_id
WHERE ST_DWithin(loc, ST_SetSRID(ST_Point(-97.7286718, 30.3033267),4326)::geography, 20 * 1609)
AND f.category IN ('desserts', 'beverages', 'entrees', 'other')
ORDER BY distance ASC;