What's the recommended way to handle joins that aggregate results?

I'm currently converting a codebase that uses raw sql postgres queries over to drizzle, and have this query:
SELECT
  games.name,
  games.image_url,
  JSON_AGG(
    JSON_BUILD_OBJECT(
      'name', game_features.name,
      'icon_url', game_features.icon_url
    )
  ) AS features
FROM
  games
  LEFT JOIN game_features ON games.id = game_features.game_id
GROUP BY
  games.name,
  games.image_url,
  games.sort_order
ORDER BY
  games.sort_order;

I was wondering what the recommended way of queries that aggregate joins using functions such as JSON_AGG or ARRAY_AGG?
Was this page helpful?