Is there a type for a Drizzle connection?
My use case is the following: I'm building a library dealing with a Neon database, but the connection shoud be created by the app using the library. So, all the functions of the lib expects as a their first parameter the actual connection to the database.
How can I type this parameter so that the function accepts both a connection created with the Neon HTTP and Websockets drivers?
Neon HTTP driver
Neon Websockets driver
I tried the following but it leads to a typescript error which I issued (https://github.com/drizzle-team/drizzle-orm/issues/3334) :
Many thanks in advance!
GitHub
[BUG]: Typescript error with returning({...}) function when combini...
What version of drizzle-orm are you using? 0.36.0 What version of drizzle-kit are you using? 0.27.0 Describe the Bug My use case is the following: I'm building a library dealing with a Neon dat...
2 Replies
Due to the complexity of the types returned by drizzle, making an union like this is very complicated.
I believe you can return a generic type to make it work, but I don't really remember the details of when I dealt with something like this
I you put your code in drizzle.run and share it, I can help you make it work
Sure! Here it is: https://drizzle.run/sc5jiwu5ecf14blj4qbgmj1h
Drizzle Run
New blank playground - Drizzle Run