What does HackerNews think of ts-sql?
A SQL database implemented purely in TypeScript type annotations.
import { Query } from "@codemix/ts-sql";
const db = {
things: [
{ id: 1, name: "a", active: true },
{ id: 2, name: "b", active: false },
{ id: 3, name: "c", active: true },
],
} as const;
type ActiveThings = Query<
"SELECT id, name AS nom FROM things WHERE active = true",
typeof db
>;
// ActiveThings is now equal to the following type:
type Expected = [{ id: 1; nom: "a" }, { id: 3; nom: "c" }];
https://github.com/codemix/ts-sql
This project was my go-to "nifty but pointless" example for TS string literal types before this article :)
This would have been much easier if I'd had ts-regexp at the time :)
https://gist.github.com/hediet/63f4844acf5ac330804801084f87a...
https://github.com/codemix/ts-sql
https://github.com/jamiebuilds/json-parser-in-typescript-ver...
https://gist.github.com/acutmore/9d2ce837f019608f26ff54e0b1c...
https://github.com/codemix/ts-sql
import { Query } from "@codemix/ts-sql";
const db = {
things: [
{ id: 1, name: "a", active: true },
{ id: 2, name: "b", active: false },
{ id: 3, name: "c", active: true },
],
} as const;
type ActiveThings = Query<
"SELECT id, name AS nom FROM things WHERE active = true",
typeof db
>;
// ActiveThings is now equal to the following type:
type Expected = [{ id: 1; nom: "a" }, { id: 3; nom: "c" }];
Edit: see this SQL made out of the type system: https://github.com/codemix/ts-sql
Massive shout out to Barld Boot who's tic tac toe implementation I based this off! https://medium.com/@bakeds/play-tic-tac-toe-with-the-help-of...