Replies: 2 comments
-
I found that whether export type DatabaseType = typeof database;
export type TransactionType = Parameters<Parameters<DatabaseType['transaction']>[0]>[0]; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello! I recently realized that drizzle actually already provides typed Are you defining a union import type { drizzle as postgres } from "drizzle-orm/node-postgres";
import type { drizzle as pglite } from "drizzle-orm/pglite";
import type * as schema from "../schema/index";
export type Schema = typeof schema;
export type Postgres = ReturnType<typeof postgres<Schema>>;
export type PGlite = ReturnType<typeof pglite<Schema>>;
export type Database = Postgres | PGlite;
const any = (db: Database) => {
// (parameter) tx: any
db.transaction(tx => {})
}
const correct = (db: Postgres) => {
// (parameter) tx: PgTransaction<NodePgQueryResultHKT, typeof schema, ExtractTablesWithRelations<typeof schema>>
db.transaction(tx => {})
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’m using Drizzle ORM and need to pass the transaction object (
tx
) to another function. Currently, I have definedtx
asany
, but I’d like to replace it with the correct, type-safe version.Here’s an example of my function:
Beta Was this translation helpful? Give feedback.
All reactions