Skip to content

Relations input #1483

Answered by Angelelz
mGasiorek998 asked this question in Q&A
Nov 9, 2023 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

Unfortunately, drizzle doesn't have an easy to use type helper for this. You might want to submit an issue.
But there are workarounds. It you don't want to depend on Drizzle's internal types, you could use some typescript magic and come up with this:

type WithInput = NonNullable<Parameters<typeof db['query']['employeesSchema']['findFirst']>[0]>['with']

If you want to use drizzle's internal types, here is how you can get to the same result:

type WithInput = DBQueryConfig<'many', true, ExtractTablesWithRelations<typeof schema>, ExtractTablesWithRelations<typeof schema>['employeesSchema']>['with']

Take a look at this playground to see this in action.

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@mGasiorek998
Comment options

@Angelelz
Comment options

Angelelz Nov 9, 2023
Collaborator

Answer selected by mGasiorek998
@Makisuo
Comment options

@Angelelz
Comment options

@jakeriksen
Comment options

@wolfgang-hartl
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants