Transaction Type
Is there a type to use for passing a transaction into a function? I would like to do something like
but the type of
tx
is super long and not convenient at all.9 Replies
recent update changed the types and now I cant fit a Drizzle Transaction type into a normal Drizzle type. I'm not sure how aware the team is about it
Yea I used to be able to just do
typeof db
and that was good enough but now the new update has changed the types. It doesn't seem there has ever been a proper way to represent that type, just work arounds.did you guys ever find a solution?
i had this same problem today, solved it this way
i personally prefer option 1 since getting it from the params seems a bit janky
(im on mobile so excuse the formatting and typos)
While this does work for me, it's obviously not how we should be getting the type. It seems crazy to me that this isn't something exposed by the library. Is it really that uncommon to need the type of a transaction? Do you know if they are planning on adding this at any point to the library itself?
i completely agree, i looked through the source code to see if such a type was exposed but nopes
that’s why i had to use these helpers but yeah not ideal
Plus, who knows if either of these will work after the next update.
and i dont work for drizzle so idk if it’s planned
option 2 will, it just takes the return type. it’s just ugly
option 1 should, since i’m just creating the PgTransaction type the same way it’s done internally in drizzle
Well, hopefully they just expose an actual type in the future. For now though your solution works, so thank you lol