How to create the type of the client with the schema

I want to create a type for the drizzle client with my schema. What I'm doing now is this:
const client = () => drizzle(neon(connectionString!), { schema });

type DrizzleClient = ReturnType<typeof client>
const client = () => drizzle(neon(connectionString!), { schema });

type DrizzleClient = ReturnType<typeof client>
but I want to be able to do something like:
type DrizzleClient = typeof drizzle<schema>
type DrizzleClient = typeof drizzle<schema>
Is there a way to do that?
5 Replies
Angelelz
Angelelz11mo ago
TBH what you're doing is perfectly fine Are you using neon serverles?
jakeleventhal
jakeleventhalOP11mo ago
i am, but am shortly switching to aws aurora serverless v2 + rds data api
Angelelz
Angelelz11mo ago
The I would keep it as is, that way, when you migrate, the type will stay in sync BTW, are you exporting your client as is? So when you need it you call client()?
jakeleventhal
jakeleventhalOP11mo ago
no, im exporting like this
const db = client();
export default db
const db = client();
export default db
Angelelz
Angelelz11mo ago
Ok, cool
Want results from more Discord servers?
Add your server