This looks great. But in my view there's still some scope for improvement in expressive-ness (compared to something like LINQ). A future area of exploration could be to add a parser to the mix, so that we can write: const jane = db.contacts.one(c => c.email === janeEmail); instead of: const jane = db.one ($.from(Contact).where(c => $`${c.email} = ${janeEmail}`))! The former is so naturally typesafe, without having to…
That won't be possible without a lot of work. You'll need to tweak the TypeScript compiler to make the parser comprehend exported variables. For example, import { contacts } from "db" const jane = contacts.one(c => c.email === janeEmail) Marco-like magic can be confusing, as we learned from Svelte. Especially when it's half-baked like the one you are suggesting. Another drawback is that you'll need to compile the cod…
When I'm giving examples on a forum thread, I try to provide one that's simpler to understand and captures the essence of the argument. I am not making any claims on completeness.
> Marco-like magic can be confusing, as we learned from Svelte. Especially when it's half-baked like the one you are suggesting.
Svelte invents new syntax, which in my view isn't great. This is pure JS, and it could even run in a browser against arrays (for tables).
Add:
> That won't be possible without a lot of work. You'll need to tweak the TypeScript compiler to make the parser comprehend exported variables.
Not required. I was suggesting that the expression could be parsed at runtime. There are various options, with different tradeoffs.