Re:PostgREST – A fully RESTful API from any existing Postgre...
by jklehm on Sunday March 26, 2017 @06:09PM
(#13963599)
You’d use these [0] functions to build a json string and return your structure, one row per root of each hierarchy (you might only return one row if you’re after a single hierarchical json object).
[0] https://www.postgresql.org/docs/9.5/static/functions-json.ht...
Re:PostgREST – A fully RESTful API from any existing Postgre...
by ruslan_talpa on Monday March 27, 2017 @02:17AM
(#13965550)
Please read the whole thread, this is the exact point i was making, json is the only way to return tree like data. willglynn was saying you can do it with "with recursive" and i think he was confusing "traversing/inspecting" tree like data with "returning" tree like data.
consider there are 3 tables clients/projects/tasks with FKs between them.
Please paste the query that returns all the information above using "with recursive"
This is how the communication between the client an PG goes https://www.pgcon.org/2014/schedule/attachments/330_postgres...
- client sends an SQL command - server replies with RowDescription detailing the structure - after that a DataRow message is sent for every row - finally, the server sends CommandComplete and ReadyForQuery
So inherently the protocol can only represent a 2D array.