SELECT
row_to_json(fc)FROM(SELECT'FeatureCollection'AStype, array_to_json(array_agg(f))AS features
FROM(SELECT'feature'AStype, ST_AsGeoJSON(geometry)::json asgeometry,(SELECT
row_to_json(t)FROM(SELECT
${fields}
)AS t
)AS properties
FROM ${tableName} wheregeometryisnotnulland id > ${startId} orderby id asc<if test="limit > 0">limit ${limit}
</if>)AS f
)AS fc