sql
SELECT
app.id,
app.name,
app.description,
app.created_at,
app.updated_at,
app.url,
app.creator_id,
app_creator.data AS creator
FROM
app
LEFT JOIN LATERAL (
SELECT
JSON_ARRAY(
user.id,
user.email,
user.role,
user.hashed_password,
user.firstname,
user.lastname,
user.created_at,
user.updated_at
) AS data
FROM
user
WHERE
user.id = app.creator_id
LIMIT 1
) app_creator ON true;
sql
SELECT
app.id,
app.name,
app.description,
app.created_at,
app.updated_at,
app.url,
app.creator_id,
app_creator.data AS creator
FROM
app
LEFT JOIN LATERAL (
SELECT
JSON_ARRAY(
user.id,
user.email,
user.role,
user.hashed_password,
user.firstname,
user.lastname,
user.created_at,
user.updated_at
) AS data
FROM
user
WHERE
user.id = app.creator_id
LIMIT 1
) app_creator ON true;