logoalt Hacker News

barishnamazovyesterday at 10:24 PM2 repliesview on HN

How is this different than kysely + kysely-codegen (or hand-made types)?


Replies

n_eyesterday at 10:59 PM

Kysely is a query builder: you build queries by calling javascript functions, while with pg-typesafe you write SQL directly.

I've used kysely before creating pg-typesafe, and came to the conclusion that writing SQL directly is more convenient.

A query builder works well for simple cases (db.selectFrom("t").where("id","=","1") looks a lot like the equivalent SQL), however, for more complicated queries it all falls apart. I often had to look at the docs to find how to translate some predicate from SQL to the required idiom. Also, I don't think kysely can automatically infer the return type of PostgreSQL functions, while pg-typed does (it asks PostgreSQL for it).

ZiiSyesterday at 10:54 PM

It only changes the types; not the code.