You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's as far as I got before stopping, in case it helps anyone who prefers Drizzle > Kysely:
importsqliteWasm,{typeDBascrDB}from"@vlcn.io/crsqlite-wasm"importcrsqliteUrlfrom"@vlcn.io/crsqlite-wasm/crsqlite.wasm?url"// https://vitejs.dev/guide/assets.html#explicit-url-importsimport{drizzle}from"drizzle-orm/sqlite-proxy"asyncfunctiongetDb(){constsqlite=awaitsqliteWasm(()=>crsqliteUrl)constdb=awaitsqlite.open("whatever.db")returndb}exportconstddb=drizzle(async(sql,params,method)=>{constdb=awaitgetDb()conststmt=awaitdb.prepare(sql)stmt.bind(params)try{if(method==="run"){awaitstmt.run(null)return{rows: [],}}elseif(method==="all"||method==="values"){constr=awaitstmt.all(null)return{rows: r.map(Object.values),}}elseif(method==="get"){return{// eslint-disable-next-line @typescript-eslint/no-unsafe-argumentrows: Object.values(awaitstmt.get(null)),}}else{console.error("Unknown method:",method)return{rows: []}}}catch(e){console.error(e)return{rows: []}}finally{awaitstmt.finalize(null)}})// ref: https://github.com/drizzle-team/drizzle-orm/tree/main/examples/sqlite-proxy// I found no relevant Google hits for SQLite's `run`, `all`, `values`, and `get` methods. Please LMK if you know wtf these mean or do.
(If you do prefer Drizzle > Kysely, please let me know why! IMO Kysely has better syntax and more features, especially with ParseJSONResultsPlugin and its ability to return nested objects/arrays).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I started to write a Drizzle adapter but eventually realized that (for me) it offered no benefits over Kysely, so I went back to using the excellent https://github.com/Azarattum/CRStore (in particular, https://github.com/Azarattum/CRStore/blob/main/src/lib/database/dialect.ts) There's also https://github.com/subframe7536/kysely-sqlite-tools, which I haven't looked closely at yet.
Here's as far as I got before stopping, in case it helps anyone who prefers Drizzle > Kysely:
(If you do prefer Drizzle > Kysely, please let me know why! IMO Kysely has better syntax and more features, especially with
ParseJSONResultsPlugin
and its ability to return nested objects/arrays).Beta Was this translation helpful? Give feedback.
All reactions