In PostgreSQL 9.4, how do I retrieve json object like this:
parentTableFirstProp: \'string\',
parentToChildReference: [
{childTableFirstProp: \'another strin
A new feature in PostgreSQL 9.2 but I didn't test the query:
I follow the tutorial from here.
select row_to_json(t)
from (
select ParentTable.parentTableFirstProp, (
select array_to_json(array_agg(row_to_json(child)))
from (
select childTableFirstProp
from ChildTable
where ChildTable.id=ParentTable.parentToChildReference
) child
) as parentToChildReference
from ParentTable
) t