P
Prisma10mo ago
francel

Single table inheritance

How to use Single Table Inheritance with prisma ?
2 Replies
StoicWanderer
StoicWanderer10mo ago
For example, if you use MySQL as db and you have a User and a Post table and inside the User table you define a type discriminator column and inside the Post table you define a foreign key of userID referencing the User table and when querying Post table, you add the type in the where clause of Post and add the include keyword for {user:true} so it returns not only the posts but the user data as well.
StoicWanderer
StoicWanderer10mo ago
Prisma
Table inheritance
Learn about the use cases and patterns for table inheritance in Prisma ORM that enable usage of union types or polymorphic structures in your application.
Want results from more Discord servers?
Add your server