codemix / codemix/ts-sql

Are there any serious projects doing this?

Offen
#8 15 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
3.3k
Forks
53
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

This is crazy impressive! 😄

What would be really cool, is if we could actually turn this into something useful.

Imagine something like this?

```ts
const sql = createShema({
users: {
user_id: type.number(),
email: type.string(255),
// ...
}
});

const userQuery = sql("SELECT * FROM users WHERE user_id = :user_id").bind({ user_id: 123 });
```

Imagine this would validate query structure and schema names, and return a type that infers the shape of the rows.

Something like [`sql-template-tag`](https://www.npmjs.com/package/sql-template-tag) but type-safe, and with placeholders (and subsequent binding) rather than template literals.

(since, sadly, typescript [doesn't](https://github.com/microsoft/TypeScript/issues/33304#issuecomment-1637784732) seem to support type-safe template literal functions...)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.