下面的脚本非常适合指定的列,我得到了预期的结果。但我想从表中获取所有列。谢谢您的帮助。
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
1条答案
按热度按时间qlzsbp2j1#
要包含所有字段(包括几何图形),您需要将表名或别名传递给
row_to_json
```select
row_to_json(lg) As properties FROM coffee_shops As lg