Closed lawzava closed 7 years ago
There's no direct support for this. The simplest way is to use dbx.NewQuery
and pass in the above SQL. If you want to use query builder, you may build the the SELECT queries and then combine them into the final SQL, although I don't quite recommend in this case.
I have a query:
SELECT * FROM products p, LATERAL ( SELECT jsonb_agg( jsonb_build_object('location', jsonb_build_object('timestamp', locations.timestamp, 'lat', st_x(locations.point), 'lon', st_y(locations.point)) ) ) FROM locations WHERE locations.product_id = p.id ) t2 ( location )
I failed to find how it would look while using dbx.