Help with Join query

Hi all, I have this three tables:

users (id, name, email)
account (id, username, public)
userAccounts (user_id, account_id, role)

I would like to get a query that for a given account it gives me the account data and all the managers that this account have. I have archived this via two queries, but I would like to do it in just one DB call.

The expected result:

[
{
username
public
managers: {
name,
email
role,
}
}
]
Was this page helpful?