Postgres denormalize tables into json objects for node Heres my problem. I have the following tables
CREATE TABLE inventory(
    id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
    owner text NOT NULL references profile(name)
);

CREATE TABLE inventory_item(
    id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
    description text,
    amount bigint,
    inventory uuid nOT NULL references table(id)
);

Now I would like to query for a single inventory

all items in that inventory
id and owner of that inventory

So I basically get a result of the following form, to send to the client:
{
   &quot;id&quot;:&quot;1234123-1234-1234&quot;,
   &quot;owner&quot;:&quot;tom&quot;,
   &quot;items&quot;:[
      {
         &quot;id&quot;:&quot;2344-123412-34&quot;,
         &quot;description&quot;:&quot;sword&quot;,
         &quot;amount&quot;:33
      },
      {
         &quot;id&quot;:&quot;6434-123412-34&quot;,
         &quot;description&quot;:&quot;apple&quot;,
         &quot;amount&quot;:23
      },
      {
         &quot;id&quot;:&quot;45454-1123412-34&quot;,
         &quot;description&quot;:&quot;bow&quot;,
         &quot;amount&quot;:32
      },
      {
         &quot;id&quot;:&quot;234234-1232412-34&quot;,
         &quot;description&quot;:&quot;arrow&quot;,
         &quot;amount&quot;:1
      }
   ]
}

I was thinking of querying id and owner directly and then adding the items as a subquery using ARRAY(). Unfortunately, ARRAY() only works with columns of the same type.
So how can I denormalize my table structure into a JSON array for node using a postgres query?
The answer was using json_agg instead of array_agg