I know this is probably on your radar but wanted to put this in. With the ability to now ATTACH db's in Turso would love the feature to be implemented.
This is my suggestion and would require Turso to have createClient() return the id of the db.
import { db as db_one } from '../server/db/first/client'
import { db as db_two } from '../server/db/two/client'
import { users as users_one } from '../server/db/one/schema'
import { users as users_two } from '../server/db/two/schema'
import { alias } from 'drizzle-orm/sqlite-core'
import { eq } from 'drizzle-orm'
const attached = alias(db_two, 'attached')
// stupid query I know, lets just say ones normal users, the other is managers/admins
const res = await db_one.attach(attached).select().from(users_two).where(eq(users_two.id, users_one.id))
This way we keep the drizzle way of building, apis stay similiar. You also get the win of separate clients/schemas, and can implement attach for other databases that don't support the ATTACH keyword but drizzle can do some magic under the hood etc.
Describe what you want
I know this is probably on your radar but wanted to put this in. With the ability to now
ATTACH
db's in Turso would love the feature to be implemented.This is my suggestion and would require Turso to have
createClient()
return the id of the db.This way we keep the drizzle way of building, apis stay similiar. You also get the win of separate clients/schemas, and can implement attach for other databases that don't support the
ATTACH
keyword but drizzle can do some magic under the hood etc.