Explicitly specifying an object in Prisma with its foreign relationships
I've set up my schema as an approximation of a directory structure: directories (
I can write queries to retrieve directories and their children (
I've circumvented this issue by extending the type with my own interface, but I feel like it's a messy fix. Any tips? Thanks.
further reference: related libs are just next (using app router) and prisma. No trpc, zod, or superjson packages, but not against them if they are key to a good implementation.
ADirs) and documents (ADocs). Directories and documents can have a parent directory, which is a foreign key.I can write queries to retrieve directories and their children (
childDirs, childDocs) without issue, but if I specify a directory as a state variable in a client component with useState, the type definition for ADir that I get from importing @prisma/clientdoes not have the children as a property.I've circumvented this issue by extending the type with my own interface, but I feel like it's a messy fix. Any tips? Thanks.
further reference: related libs are just next (using app router) and prisma. No trpc, zod, or superjson packages, but not against them if they are key to a good implementation.