I want to select some categories and sub categories and want to show it all in one array like this:
[
{
category: 'ELECTRONICS',
sub_category: 'CONSOLE'
}
]
but I got this:
[
{ f1: 'ELECTRONICS', f2: 'CONSOLE' },
{ f1: 'ELECTRONICS', f2: 'CONSOLE' }
]
here is a code snippet
SELECT
s.id,
s.name,
s.image,
s.verified,
s.s_position,
s.status,
s.platform,
s.coupon_name,
s.coupon_pct,
s.coupon_start,
s.coupon_end,
json_agg(row(c.category, scg.sub_category)) as categories
....
json_build_object? postgresql.org/docs/9.5/functions-json.html