Postgres json_agg

How can I create this equivalent using drizzle?

select
  p.id,
  p.description,
  p.name,
  json_build_object(
    'id',
    b.id,
    'name',
    b.name
  ) as brand,
  json_agg(
    json_build_object(
      'id',
      v.id,
      'name',
      v.name
    )
  ) as variant
from
  product as p
  inner join brand as b on b.id = p.brand_id
  inner join product_variant as v on v.product_id = p.id
group by p.id, b.id


I cannot find any article in the docs.
Was this page helpful?