need help abstracting a function
This may be an easy answer but how can I implement the following type?
is this abstractions stupid? I would like withConfig to be correctly typed. Does it make sense or should I just repeat the function and be free?
Solution:Jump to solution
GitHub
Relations input · drizzle-team drizzle-orm · Discussion #1483
I have a schema that looks like somewhat like this: export const employeesSchema = pgTable('employees', { firstName: varchar('first_name', { length: 256 }), lastName: varchar('l...
9 Replies
Lol, did you ask this question in the discussions in github?
Solution
GitHub
Relations input · drizzle-team drizzle-orm · Discussion #1483
I have a schema that looks like somewhat like this: export const employeesSchema = pgTable('employees', { firstName: varchar('first_name', { length: 256 }), lastName: varchar('l...
You can adapt that answer to what you need
Damn that's awfully similar to my problem haha
yes it works, thanks for the answer
Thanks, this was helpful... I'm still trying to get the query client to change its return type based on what relations are passed in.
@Aaron did you managed to type the response incluiding the relations? Really struggling with this now...
@Stathis yeah, i've been doing:
this provides proper autocomplete and typesafety 😄
@Aaron sorry for bumping you again, how to do you type function parameters? eg. I want to pass the result to a function:
No matter what I tried I could not type the
with
, in this case post.post_images
you can likely just do something like this within your schema definitions?
there's probably other ways to infer the posts relationship using some drizzle types but I'd have to play around a bit to see