drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: allow multiple adapters on withReplicas
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
Here is my code, and I have tested it. However, it has a TypeScript error.
I am unsure if this is not allowed or just a TypeScript error.
If you're wondering why I'm combining `postgres` and `neon`, it's because `neon` doesn't support transactions yet.
```ts
import { neon, neonConfig } from '@neondatabase/serverless'
import { drizzle as drizzleNeon } from 'drizzle-orm/neon-http'
import { withReplicas } from 'drizzle-orm/pg-core'
import { drizzle as drizzlePostgres } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import * as schema from '../database/schema'
import type { Env } from '../env'
neonConfig.fetchConnectionCache = true
export function createDb({ env }: { env: Env }) {
const write = drizzlePostgres(postgres(env.DATABASE_URL), {
schema,
logger: env.WORKER_ENV === 'development',
})
const read = drizzleNeon(neon(env.DATABASE_URL), { schema, logger: env.WORKER_ENV === 'development' })
// @ts-ignore TODO: fix type for withReplicas
return withReplicas(write, [read])
}
```
Contributor guide
Assessment
This issue has not been assessed yet.