drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too šŸ˜…
https://orm.drizzle.team
Apache License 2.0
23k stars 550 forks source link

Add SQLite WASM driver support #193

Open AndriiSherman opened 1 year ago

Azarattum commented 1 year ago

Is this for the official SQLite wasm or for something like wa-sqlite (which from my understanding is currently superior to the official build)?

AndriiSherman commented 1 year ago

@Azarattum yes, we were looking into using official SQLite wasm

jordanhboxer commented 1 year ago

Hi @AndriiSherman ā€“ any update on this? I can try to help if you need

ShravanSunder commented 1 year ago

@AndriiSherman Would it be possible to know how this is going?

DallasHoff commented 1 year ago

Recently, I've been working on a library to make SQLite WASM easier to use, and I found that making it work as a driver for Drizzle was actually pretty easy. If you need this, I hope it helps you out: https://sqlocal.dallashoffman.com/drizzle/setup

For migrations, I've been looking into making a PR to Drizzle to add a version of their migrate function that works on the frontend. It should be possible. I'll probably make an issue first just so the Drizzle guys have a chance to say "no thanks" or "we already have this halfway done" first. Hopefully there's interest from them.

ShravanSunder commented 1 year ago

@DallasHoff do you have feature list for drizzle that your lib covers? Nice work, and nice docs too!

DallasHoff commented 1 year ago

@ShravanSunder Querying and anything else that you do through the main drizzle function should work. It's just migrations that need work since Drizzle's migrate function only works in Node.js, but everything else looks to work just fine in the browser. Drizzle handles the schema definition and query building stuff. It passes the raw SQL for the query to SQLocal acting as the driver, and SQLocal takes that, passes it to the SQLite WASM database, and returns any result data back to Drizzle. It's like any other driver except instead of communicating with a remote server running the database, the database is running in a web worker.

DallasHoff commented 1 year ago

For migrations, I've been looking into making a PR to Drizzle to add a version of their migrate function that works on the frontend. It should be possible. I'll probably make an issue first just so the Drizzle guys have a chance to say "no thanks" or "we already have this halfway done" first. Hopefully there's interest from them.

Here's that issue for those interested: #1009

sjunepark commented 11 months ago

@DallasHoff I had a hard time setting up sqlite wasm, and had no idea I would stumble into such a project here. Will try it out thanks.

AntonOfTheWoods commented 8 months ago

@AndriiSherman Just out of curiosity, was this deprioritised due to it being more complicated than expected or lack of interest?

Sheraff commented 5 months ago

@AndriiSherman I wrote an adapter for crsqlite-wasm (from Vlcn https://vlcn.io/docs/cr-sqlite/intro). As far as I can tell, this seems to be working. It's heavily inspired from the better-sqlite3 and the libsql adapters from this very repo.

Here's the published package for it: https://www.npmjs.com/package/drizzle-orm-crsqlite-wasm.

I have a few questions, of which you can answer between none and all (no worries, I know OSS is draining!):

AntonOfTheWoods commented 5 months ago

There seem to be a lot of interest in generating hype but not much interest in making things useful. "Support" for pglite has been added, which is still very much proof-of-concept/pre-alpha, which is also a browser-based db but still no examples on how this might actually be useful, given there is no way to make migrations happen.

DallasHoff commented 5 months ago

@AntonOfTheWoods Be sure to give #1009 a thumbs up if you haven't already so that the maintainers know that there is interest.

AntonOfTheWoods commented 5 months ago

@AntonOfTheWoods Be sure to give #1009 a thumbs up if you haven't already so that the maintainers know that there is interest.

@DallasHoff Unless I'm mistaken, none of the maintainers have even bothered to comment on that ticket, which seems to have garnered at least a modicum of interest. Not giving me much confidence in the health of the project ecosystem...

zackify commented 3 months ago

I saw a maintainer say it was on the roadmap last march, can someone at least respond from the drizzle team?

Iā€™m going to sponsor them in hope of getting this issue looked at