【发布时间】:2020-11-11 23:15:07
【问题描述】:
下面的脚本非常适合指定的列,我得到了我期望的结果。但我想从表中获取所有列。谢谢你的帮助。
SELECT row_to_json(fc) FROM (
SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM(
SELECT 'Feature' As type, ST_AsGeoJSON(lg.geom)::json As geometry,
row_to_json((id, name)) As properties FROM coffee_shops As lg
) As f
) As fc
【问题讨论】:
-
你好。您还可以添加表结构、一些数据样本和确切的预期结果吗?
-
"type":"FeatureCollection","features":[{"type":"Feature","properties":{"id":1,"name":"1369 Coffee House" ,"address":"1369 Cambridge St","city":"Cambridge","state":"MA","zip":"02139"},"geometry":{"type":"Point","坐标":[-71.10044,42.373695]}} 预期结果
-
请添加您的表结构以获得精确的 quary
标签: javascript sql node.js postgresql postgis