automatic flatten nested query result

I have schema that looks like this:

users <--manyTomany--> roles <--manyTomany--> permissions

I implemented all the required bridge tables and I am able to query a user, its roles and its permissions with the with: {} query api

the result that I is very nested and I would like to know if there is a way to direcly get all permissions of a user even if it is hidden in a many to many relationship?

I could do that with some map and Set logic, but does maybe drizzle offers you some utils for that?
Was this page helpful?