Less verbose generic types for helper functions
Trying to implement various helper functions to join or filter data, I keep facing the need to add quite verbose generic types whenever I want to handle subqueries and/or selections alongside tables. Are there type helpers I'm unaware of that could make things a bit more straightforward? Here's an example illustrating what I mean:
I could implement some type helpers of my own, but was wondering if anything was already included in
drizzle-orm
7 Replies
Don't have an answer for you but this is a huge deal breaker for me when using drizzle to not have the ability to wrap queries with my own functions
So If you find a solution I'll appreciate it if you can share it here 🙂
Do you have an example of wrapper function you'd plan on working with? It could maybe help me sketch out more robust type helpers
Step one to help work with subqueries for me is to provide a config getter:
With simplified types:
I don't we are going for the same thing, I'm looking more for a domain specific wrapper functions, where the only generic thing is providing a projection while maintaining type safety, something like so:
did either of you ever get a decent set of wrappers working?
Yeah, i made a package with various type / query helpers to help me reuse some wrappers across projects: https://github.com/iolyd/drizzle-orm-helpers
GitHub
GitHub - iolyd/drizzle-orm-helpers: Collection of unofficial helper...
Collection of unofficial helpers for Drizzle ORM. Contribute to iolyd/drizzle-orm-helpers development by creating an account on GitHub.
You can look at the source and copy what you want (or you can install the package but I'm still changing things quite a lot so i'd say its a bit unstable)
wow this looks great! thank you for this!