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
// Setting up a connection with Neon HTTP driver// See the Drizzle doc:// - https://orm.drizzle.team/docs/connect-neon page// - Section "Step 2 - Initialize the driver and make a query"// - Tab "Neon HTTP"import { drizzle } from 'drizzle-orm/neon-http' // <-- neon-http hereconst db = drizzle(url)
// Setting up a connection with Neon HTTP driver// See the Drizzle doc:// - https://orm.drizzle.team/docs/connect-neon page// - Section "Step 2 - Initialize the driver and make a query"// - Tab "Neon HTTP"import { drizzle } from 'drizzle-orm/neon-http' // <-- neon-http hereconst db = drizzle(url)
Neon Websockets driver
// Setting up a connection with Neon HTTP driver// See the Drizzle doc:// - https://orm.drizzle.team/docs/connect-neon page// - Section "Step 2 - Initialize the driver and make a query"// - Tab "Neon Websockets"import { drizzle } from 'drizzle-orm/neon-serverless' // <-- neon-serverless hereimport ws from 'ws'export const db = drizzle({ connection: url, ws: ws })
// Setting up a connection with Neon HTTP driver// See the Drizzle doc:// - https://orm.drizzle.team/docs/connect-neon page// - Section "Step 2 - Initialize the driver and make a query"// - Tab "Neon Websockets"import { drizzle } from 'drizzle-orm/neon-serverless' // <-- neon-serverless hereimport ws from 'ws'export const db = drizzle({ connection: url, ws: ws })
import { drizzle as http } from 'drizzle-orm/neon-http'import { drizzle as ws } from 'drizzle-orm/neon-serverless'export type DB = ReturnType<typeof http> | ReturnType<typeof ws>
import { drizzle as http } from 'drizzle-orm/neon-http'import { drizzle as ws } from 'drizzle-orm/neon-serverless'export type DB = ReturnType<typeof http> | ReturnType<typeof ws>
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...