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:
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.
4 Replies
Maybe a select statement, but how can I turn the relation into an array?
Or something like the example in the second case https://playground.prisma.io/examples/reading/relations/nested-reads
Prisma Playground | Learn the Prisma ORM in your browser
Prisma Playground | Learn the Prisma ORM in your browser
The Playground is an interactive learning environment for Prisma. Learn how to send database queries and explore migrations workflows with the Prisma ORM.
I didn't see your relations, assuming they are correct, you can use the relational query builder:
I wanted to simplify the object, as the array that it returns is too complex and brings extra information