Transform output/ simplified relationship

Hi! This question may be a bit dumb and has other solutions, like just creating a function to achieve what a i want, but i wanted to see if it was achievable with the Drizzle, I'm trying to implement RBAC, but im trying to store all of this in my on database and replicate the RBAC to my provider, basically I want to be able to query the user and get all of its roles and its permissions, like something like this:

{
  "id": 1,
  "supertokensId": "1f7043f8-7e98-48d7-a55e-9379071f3181",
  "username": "tacomaster8",
  "name": "test",
  "paternal_last_name": "mctest",
  "maternal_last_name": "test",
  ... more user details
  "userRoles": [
    {
      "name": "test role 1",
      "resource": "cabin",
      "rolePermissions": [
        {
          "id": 2,
          "name": "test1"
        }
      ]
    },
    {
      "name": "test roles 2",
      "rolePermissions": [
        {
          "id": 1,
          "name": "TEst"
        }
      ],
      "resource": "dev"
    }
  ]
}


I'll attach screenshot for my current response and definitions, am i doing somthing wring with the definitions? Maybe im not getting the schema definition part to achieve what i want.
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
Was this page helpful?