Live data from Hacker News

Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

github.com

1–10 of 87 posts

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#2
Hi everyone. A bit more than two years ago I released the first version of Postgres.js. A fully featured PostgreSQL driver for Node.js written as a learning experience out of curiosity and annoyance with the current options. It greatly outperformed the alternatives[1] using pipelining and prepared statements, while providing a much better development experience safe from SQL injections. Since then I've been busy building things using it, now running in production, and although quite delayed I'm so happy to release a new major today with some really exciting new features:

1. Realtime subscribe to changes through Logical Replication [2]

It's now possible to use logical replication to subscribe in realtime to any changes in your database with a simple api like `sql.subscribe('insert:events', row => ...)`. Inspired from Supabase Realtime you can now have it yourself in Node.

2. A Safe Dynamic Query Builder

Nesting the sql`` tagged template literal function allows building highly dynamic queries while staying safe and using parameterized queries at the same time.

3. Multi-host connection URLs for High Availability support

It's really nice to be able to quickly spin up a High Availability Postgres setup using pg_auto_failover[3] and connect using Postgres.js with automatic failover and almost 0 downtime.

4. Deno support

It also works with Deno now, completing all tests except a few SSL specific ones which requires fixes in Deno.

5. And much more

Large object support, efficient connection handling for large scale use, cancellation of requests, Typescript suport, async cursors.

[1] https://github.com/porsager/postgres-benchmarks#results

[2] https://github.com/porsager/postgres#realtime-subscribe

[3] https://github.com/citusdata/pg_auto_failover

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#3
post #2

Hi everyone. A bit more than two years ago I released the first version of Postgres.js. A fully featured PostgreSQL driver for Node.js written as a learning experience out of curiosity and annoyance with the current options. It greatly outperformed the alternatives[1] using pipelining and prepared statements, while providing a much better development experience safe from SQL injections. Since then I've been busy buil…

Congrats on the release - as I mentioned on twitter, your templating design is the best DX i've seen for any PG client.

> Inspired from Supabase Realtime you can now have it yourself in Node.

Very cool! We have some Node servers internally, I'll see if the team want to switch.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#4
post #2

Hi everyone. A bit more than two years ago I released the first version of Postgres.js. A fully featured PostgreSQL driver for Node.js written as a learning experience out of curiosity and annoyance with the current options. It greatly outperformed the alternatives[1] using pipelining and prepared statements, while providing a much better development experience safe from SQL injections. Since then I've been busy buil…

Congrats on the release - as I mentioned on twitter, your templating design is the best DX i've seen for any PG client. > Inspired from Supabase Realtime you can now have it yourself in Node. Very cool! We have some Node servers internally, I'll see if the team want to switch.

Thanks - that's really nice to hear!

That would be really interesting. Are you using `pg` currently, and are you using WebSocket connections in Node to Elixir for realtime, or not using realtime in Node?

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#6
What a coincidence seeing this on HN. Great lib! I actually experimented with replacing our use of node-postgres with this today. Your lib was the reason I finally got around to shipping support for tagged template literals in Imba today (https://github.com/imba/imba/commit/ae8c329d1bb72eec6720108d...) :) Are you open for a PR exposing the option to return rows as arrays? It's pretty crucial for queries joining multiple tables with duplicate column names.

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#7
post #6

What a coincidence seeing this on HN. Great lib! I actually experimented with replacing our use of node-postgres with this today. Your lib was the reason I finally got around to shipping support for tagged template literals in Imba today ( https://github.com/imba/imba/commit/ae8c329d1bb72eec6720108d... ) :) Are you open for a PR exposing the option to return rows as arrays? It's pretty crucial for queries joining mul…

Thanks a lot! What a coincidence - and perfect timing since v3 supports .raw()[1] to receive results as arrays.

I'd also be very curious to hear how replacing pg goes :)

And also good job on Imba! I'm a really big fan of stripping syntax down to the bare essentials, and what you've done with Imba is really impressive!

[1] https://github.com/porsager/postgres#raw

Re: Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno

#8
post #4

Earlier quoted context omitted.

Congrats on the release - as I mentioned on twitter, your templating design is the best DX i've seen for any PG client. > Inspired from Supabase Realtime you can now have it yourself in Node. Very cool! We have some Node servers internally, I'll see if the team want to switch.

Thanks - that's really nice to hear! That would be really interesting. Are you using `pg` currently, and are you using WebSocket connections in Node to Elixir for realtime, or not using realtime in Node?

yes, we use `pg` in all our Node servers (and no realtime)
Post reply on HN