Re:Litdb – type safe SQL for JavaScript/TS
by norman784 on Friday December 06, 2024 @05:06AM
(#42338215)
I was thinking on how a library could work with the type inference, one idea that came to mind is to have some script running in the background (if you are using a bundler, you might be able to hook into it) that search for all sql tag templates, execute them against a live database to validate and get the result structure. This is how sqlx[0] works and might is worth exploring more in deep.
One downside of course is that AFAIK typescript is not powerful enough to match all queries to types, so my idea was to build a .d.ts file that maps the queries with the result.
ts-safeql seems to work with a lsp plugin? I didn't dig into how lsp and plugin works, so I cannot speak of if my approach will work with it, but I suppose no, because it needs to generate files.
Re:Litdb – type safe SQL for JavaScript/TS
by alexkbog on Friday December 06, 2024 @02:11PM
(#42343123)
You should check out sdf (semantic data fabric). https://sdf.com
You can find it here: https://github.com/nikeee/sequelts