Suggested way to use multiple drivers

Is there a suggested way to use multiple drivers?
import { drizzle } from 'drizzle-orm/neon-http';
import { drizzle as localhostDrizzle } from 'drizzle-orm/postgres-js';

const client = () => {
if (process.env.SERVER) {
return drizzle(neon(connectionString), { schema });
}

return localhostDrizzle(postgres(connectionString), { schema });
};
import { drizzle } from 'drizzle-orm/neon-http';
import { drizzle as localhostDrizzle } from 'drizzle-orm/postgres-js';

const client = () => {
if (process.env.SERVER) {
return drizzle(neon(connectionString), { schema });
}

return localhostDrizzle(postgres(connectionString), { schema });
};
Above is what im currently doing (using pg docker image for my local db), but it seems sketchy since all the code I use to test locally is actually different from what gets ran in live environments. Is there a better way?
3 Replies
jakeleventhal
jakeleventhalOP11mo ago
yeah, i think casting wouldnt be the best idea. I suppose i could cast it that way, but it seems unwise to test different from how you run prod there are a number of issues in the GH repository about bugs with specific drivers. seems like a lot of behavior would have to be double checked in a live env connected to neon to really validate any behavior
Angelelz
Angelelz11mo ago
That's completely up to you. The runtime behaviour should be the same when working with the same underlying dialect I've seen people work on SQLite db in dev and Postgres in prod. They make it work.
Want results from more Discord servers?
Add your server