Live data from Hacker News

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

github.com

11–20 of 87 posts

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

#12
Excellent work as usual, Rasmus! :) Loved my time with postgres.js in past projects, looking forward to checking out v3 in an upcoming project of mine. The speed and lack of any dependencies, while being so full-featured is really attractive.

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

#13

``` const users = await sql` select name, age from users where age > ${ age } ` ``` Do template literals like this in JS work differently than just straight up string interpolation? As a rails dev this set off alarm bells.

Yeah, when a function is called as a "tagged template literal"[1] the function takes control over how the parameters are handled. Postgres.js uses this to replace the value with $1, $2, etc and send over the value as parameters to the database, thereby preventing any chance of SQL injection[2].

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2] https://github.com/porsager/postgres#await-sql---result

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

#14

Looks good from what I see. How does this compare with slonik? Also what do the error messages look like?

Slonik is a wrapper around another Node.js postgres driver (pg). I guess slonik could be built on top of Postgres.js, but I'm not sure what the benefit would be since you get the same and more from Postgres.js. If you have an existing project using slonik it might benefit from the better performance if replacing pg with Postgres.js underneath (https://github.com/porsager/postgres-benchmarks#results)

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

#15

``` const users = await sql` select name, age from users where age > ${ age } ` ``` Do template literals like this in JS work differently than just straight up string interpolation? As a rails dev this set off alarm bells.

Yeah, when a function is called as a "tagged template literal"[1] the function takes control over how the parameters are handled. Postgres.js uses this to replace the value with $1, $2, etc and send over the value as parameters to the database, thereby preventing any chance of SQL injection[2]. [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2] https://github.com/porsager/postgres#await-sql---res…

nice!

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

#17
post #16

Is raw using binary protocol? (for ex: send\receive UInt8Array Buffer without converting to hex string for bytea column)

No, that unfortunately didn't make it into this release. I want to add that in a future update, first at least for bytea, but then also for other types that benefit from it.

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

#18
Very cool!

Would you consider this production ready ? I rarely if ever use relational databases for my personal projects, but this could be a great fit at work.

Also , anyway to add an orm layer. I use Firebase right now, so I'm use to that vs writing queries.

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

#19

Very cool! Would you consider this production ready ? I rarely if ever use relational databases for my personal projects, but this could be a great fit at work. Also , anyway to add an orm layer. I use Firebase right now, so I'm use to that vs writing queries.

Thanks. Definitely production ready, and I've been using it for quite a while in production myself, towards this release.

About the ORM layer I wouldn't know, since I much prefer to avoid that at any cost.

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

#20
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…

I hit a small type issue migrating from v2 to v3 that's not listed in the migration: https://github.com/porsager/postgres/issues/283
Post reply on HN