5 ms·
I feel obliged to namedrop Zapatos here, another postgres JS client with a remarkably similar design (sql in template strings), but fully typesafe. If TypeScrip
by skrebbel 3y ago
I feel obliged to namedrop Zapatos here, another postgres JS client with a remarkably similar design (sql in template strings), but fully typesafe. If TypeScript is your thing, you might appreciate it: https://jawj.github.io/zapatos/ https://jawj.github.io/zapatos/
Personally I feel it’s one of the best designed (and documented) TS libraries out there and I’m sad it’s not very well known.
- willtemperley 3y agoAt first glance Zapatos doesn't appear to be Cloudflare workers compatible though I'd love to be corrected.
- gmac 3y agoIt should be, now that pg runs fine there. If it’s not, please file an issue! It also works with @neondatabase/serverless on platforms without TCP connections (though it’s on my TODO list to make this less fiddly): https://github.com/neondatabase/neon-vercel-zapatos https://github.com/neondatabase/neon-vercel-zapatos
- 9dev 3y agoSeconded. The lateral join features in combination with the shortcut functions make it exceptionally easy to build backends with actual SQL, without compromising on ease of use.
- xctr94 3y agoWe had to abandon Zapatos because a) it doesn’t support multiple schemas; b) the types wouldn’t always be very readable. PgTyped was the alternative, and 2 years later I’m very glad we made the switch.
- Exuma 3y agoWhat do you mean multiple schemas ? What is an example of a non readable type?
- pimeys 3y agoLike this, it's pretty common way to use Postgres (with multiple schemas): CREATE SCHEMA a; CREATE SCHEMA b; CREATE TABLE a.foo (id SERIAL PRIMARY KEY); CREATE TABLE b.foo (id SERIAL PRIMARY KEY);
- xctr94 3y agoI didn’t know support for schemas had landed, but the docs still seem obtuse for joins and upserts. Compared to plain SQL files in PgTyped — which admittedly needs some annotations to work, and lacks transactions —, I find the lateral joins in Zapatos really verbose and ugly. Lots of extra parameters too. Which isn’t to say it’s not a great tool! You pick what you like :)
- alde 3y agoGlad you are liking pgTyped. Transactions are supported as pgTyped is just a thin wrapper around node-postgres: https://github.com/adelsz/pgtyped/discussions/448 https://github.com/adelsz/pgtyped/discussions/448
- xctr94 3y agoAh, I meant having a single transaction in a SQL file, as that’s how we’re using it. So having multiple queries with a BEGIN and COMMIT wrapping them.
- hhfdsbvc 3y ago
- jokesterfr 3y agoDo you know why zapatos relies on pg and not PostgresJs?