Open justserdar opened 3 months ago
I've finished my research and testing.
There is no need to create a new adapter/connector or integration for Turso DB support, it already works as it is.
The hardcoding of 'file:' in the libsql module apparently somewhere overrides itself when you enter a libsql:
url, which just dissolves the entire problem to begin with.
I have a article available with the current build of Nuxt (excluding the experimental databse(db0) module for comparison sake). You can test the current build (Nuxt 3.10) with @libsql/client directly in Nitro 'server/utils/db.ts' route. Article Github Repo
I'm finishing up my update post about the new experimental route. "Nuxt Experimental Features: Connect your Turso DB natively with db0 and Drizzle" Github Repo Nightly Branch
The new db0 module offers so much extra DX, I wish you knew how happy I am with it already.
Great work! I really hope this makes it into the main Nuxt build. With your permission I'll update the docs for usage inside Nitro/Nuxt, because currently I don't think this is clear at all.
Describe the feature
I believe I'm close to having it working, will PR soon if nobody else does.![image](https://github.com/unjs/db0/assets/67746033/a670d560-baf2-45ba-aa4f-399fdf16b2ed)
Runs the tests fine, I have visual output in browser with Drizzle Studio. I started running some quick Nuxt 3 tests with forked builds of db0. Also noticed there are multiple ways to go by this... .
The connector runs on
./libsql/node
and relies onurl
andauthToken
instead of local filePath. The way I went about it is just by creating a./libsql/turso.ts
version of./libsql/node
. You could technically do the same if the 'file:' prefix wasnt hardcoded for local dev db's.From a Full Stack development pov, I would personally love to automagically detect wether your running
better-sqlite3
locally by simply ommitting or including your Turso .env variables.Here's an example just using db0:
Here's basic config with Nuxt 3 / Nitro
Basic usecase in Nuxt 3/ Nitro
Experimental route Nuxt 3/ Nitro/ db0
./server/utils/db.ts
Would love to see this happen! Even sounds catchy like, Drizzle... UseDatabase!!
Additional information