kikko-land / kikko

Powerful SQLite adapter for web, mobile and desktop. Build reactive UI on top of it
https://kikko-doc.netlify.app/
MIT License
134 stars 8 forks source link

Typesafe queries builder? #113

Open quolpr opened 1 year ago

quolpr commented 1 year ago

Should I build a typesafe query build by myself, or adopt Kysely? Kysely actually looks cool, but I am afraid that it brings some abstraction that we don't actually need. It will be best if it is possible to decouple query execution from Kysely.

I need to discover more how overall Kysely will work with Kikko right now.

Also, @astahmer made a good work on integration kysely to Kikko, I should take a look into it.

astahmer commented 1 year ago

hey, my 2 cents:

kysely does a fine job and looks like a robust & popular solution, so people might like re-using knowledge they already acquired rather than get to know another way of doing things (which is not wrong ofc, but then you introduce a learning curve if you have difference with existing options)

about the query execution, in my experimental repo I actually didn't use kysely to run any queries: https://github.com/astahmer/vite-kikko-models/blob/19f75353dcb93cd8d08669d9787066451cd36e97/src/db-client.ts#L29-L31

instead, I would just generate the needed SQL through kysely's query builder and then execute it with kikko's https://github.com/astahmer/vite-kikko-models/blob/main/src/offline/List.tsx#L20-L32

https://github.com/astahmer/vite-kikko-models/blob/main/src/db-client.ts#L53 https://github.com/astahmer/vite-kikko-models/blob/main/src/lib/kyselyToKikkoISql.ts#L9

so i'd say, maybe the query builder shouldn't be a priority for you, maybe there are some features more important that you could address first ?

not so related but at first I found you & kikko cause I was looking for a way to have a sane way to get offline storage -> run SQLite in browser (for a side-project I made where I currently have a mini homemade ORM that I wanted to trash asap) and was looking for a way to have a built-in way to have online-replication, is that planned ? (maybe using something similar as this https://github.com/quolpr/harika/blob/main/packages/sync-common/src/HybridClock.ts ?)

if you have any questions please tell me, I'm still very interested in kikko ! (even tho I'm quite busy with other projects atm)

quolpr commented 1 year ago

Good points regarding kysely and learning curve 👍

not so related but at first I found you & kikko cause I was looking for a way to have a sane way to get offline storage -> run SQLite in browser (for a side-project I made where I currently have a mini homemade ORM that I wanted to trash asap) and was looking for a way to have a built-in way to have online-replication, is that planned ?

Actually, I think about to adopt https://github.com/vlcn-io/cr-sqlite when it will be ready to use. But yeah, offline sync is a critical thing for such kind of lib.

astahmer commented 1 year ago

that would be perfect ! I'm also following this project and it looked very promising

so would that mean online/offline synchronized state for free if kikko provides a way to use vlcn cr-sqlite ?