drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.17k stars 564 forks source link

[DOCUMENTATION]: Types documentation of transactions #2851

Open ToBaer94 opened 2 weeks ago

ToBaer94 commented 2 weeks ago

What version of drizzle-orm are you using?

0.32.0

What version of drizzle-kit are you using?

0.23.0

Describe the Bug

When working with drizzle in our project, we noticed that declaring the type of the transaction when passing it to a function was kind of unclear at first regarding what we needed to pass for the parameters:

export abstract class MySqlTransaction< TQueryResult extends MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = Record<string, never>

I think adding a comment here that explains the parameters or an example how to use it could be helpful

Expected behavior

No response

Environment & setup

No response

xl0 commented 2 weeks ago

I have the exact same use case (seeding a DB with a large number of entries) and need to pass tx to functions. Does tx: typeof db look like a solution, since tx and db have a similar type?