Get return-type from QueryBuilder
I do not have a connection to a DB, I just use the query-builder for SQL generation.
I try to write a simple function, that takes a querybuilder query in and should return a object of the result type, as if I have awaited a DB with the query:
(I use another db to fetch data - but I need the type from drizzle) This is the return-type:
When it should be:
How do I type this correctly?
I try to write a simple function, that takes a querybuilder query in and should return a object of the result type, as if I have awaited a DB with the query:
(I use another db to fetch data - but I need the type from drizzle) This is the return-type:
When it should be:
How do I type this correctly?
3 Replies
After digging through alot of issues, i fund this:
https://github.com/drizzle-team/drizzle-orm/pull/1662
So it seems not possible (yet?)
GitHub
[All] Fix: export internal types by Angelelz · Pull Request #1662 ·...
Closes #561 and closes #1319.
Added index.ts to src/query-builders to allow the build script to pick it up.
Added query builders to the index.ts files to all the dialects.
I managed to get a hacky solution, I would be able to infer the types, such that the caller-side has no types explicitly stated
Also related (kind of):
https://github.com/drizzle-team/drizzle-orm/issues/948
GitHub
[FEATURE]: Ability to specify selected fields dynamically · Issue #...
Describe what you want I have a model on my project that fetching users from the database. Each time I need different set of fields and I would like to define a function with generics so only the e...