Re: Convert a row to a nested JSON document containing all relations in PostgreSQL

2019-09-08 Thread Adrian Klaver
On 9/8/19 5:22 AM, Ali Alizadeh wrote: 1) What side are you talking about, the parent of the record or the children? the children. only one level of depth is fine. 2) What procedural language are you using? PL/pgSQL As I understand, I need to loop over all columns in the "NEW" record, fi

Re: Convert a row to a nested JSON document containing all relations in PostgreSQL

2019-09-08 Thread Ali Alizadeh
> 1) What side are you talking about, the parent of the record or the > children? the children. only one level of depth is fine. > 2) What procedural language are you using? PL/pgSQL As I understand, I need to loop over all columns in the "NEW" record, find out if the column is a foreign key

Re: Convert a row to a nested JSON document containing all relations in PostgreSQL

2019-09-07 Thread Adrian Klaver
On 9/6/19 9:35 PM, Ali Alizadeh wrote: Hello. In PostgreSQL 10.10, I have created a trigger function that converts the `|NEW|` row to a JSON object using |`to_jsonb(NEW)|`. But now I need to include the records on the other side of the foreign keys in |`NEW|` record in the JSON object in a n