Have to say, if you like to do bare metal SQL, using the nice features of Postgres, working with this lib is a total Joy!<p>No “fancy” and bleeding abstractions like something like Prisma, not convoluted type annotations like other TS libs, no, just plain SQL statements in the best JavaScript way of doing it.<p>I discovered learning to do Postgres a couple years ago, after getting sick of trying to hack Prisma, tried out several others, and after a couple minutes using this, i knew I wasn’t going back.
This library is proper fast. Don't get distracted comparing this to other libraries just on the basis of similar string template syntax; it doesn't have a dependency on pg because it implements its own low level client.<p>I've built systems on this loading multiple 10k records at time and it crushes.
Perhaps not as featured as OP’s but I’ve found <a href="https://pgtyped.dev/" rel="nofollow noreferrer">https://pgtyped.dev/</a> useful. Queries are written as SQL files, and pgtyped creates typed functions you call with query parameters.
>> Prepared statements will automatically be created for any queries where it can be inferred that the query is static<p>What does this mean in practice? Like, actual prepared statements are created against the DB session if there are no bound variables, even if that query is only made once?<p>If so, it's an interesting but highly opinionated approach...
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: <a href="https://jawj.github.io/zapatos/" rel="nofollow noreferrer">https://jawj.github.io/zapatos/</a><p>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.
I was wondering how old this project is:<p>v1.0.1 - Jan 2020<p>v2.0.0 - Jun 2020 but never left beta.<p>v3.0.0 - Mar 2022, which appears to be when the project really got started.<p>I also wonder how solid it is, because it looks very interesting.
Terrible name, makes it impossible to search on.<p>The problems start immediately when you realize it’s interchangeably called “Postgres”.<p>Any other name would have been better as long as it’s distinctive.<p>Even so I use it, best Postgres javascript library.
Shout out to <a href="https://www.npmjs.com/package/sql-template-strings" rel="nofollow noreferrer">https://www.npmjs.com/package/sql-template-strings</a>, which does a similar template string SQL escaping standalone.
The benchmarks linked to don't compare PostgresJs to Prisma. That would be useful.<p>Also the link text (Fastest full-featured node & deno client) should include the word benchmark, for those looking for one.
Been using pg-promise[1] for years (for Node). How does this compare - is there a reason to switch?<p>[1]: <a href="https://github.com/vitaly-t/pg-promise">https://github.com/vitaly-t/pg-promise</a>
Super happy user of this [1] it's rather minimalistic but great.<p>[1] <a href="https://github.com/Ff00ff/mammoth">https://github.com/Ff00ff/mammoth</a>
Can anyone explain to me the purpose of tagged template strings?<p>From what I understand it’s only a function that takes in a string, so this might have just been sql(‘…’).
For people who would like a more safe and structured approach (but almost as powerful and with the option to resort to SQL strings if needed) I highly recommend checking out Prisma <a href="https://www.prisma.io/" rel="nofollow noreferrer">https://www.prisma.io/</a>
reposting my comment on its benchmarks:<p>On what makes it postgres.js faster, from author himself:<p>> it seems Postgres.js is actually faster than, not only pg, but of any driver out-there<p>- <a href="https://github.com/porsager/postgres/discussions/627">https://github.com/porsager/postgres/discussions/627</a><p>- <a href="https://porsager.github.io/imdbench/sql.html" rel="nofollow noreferrer">https://porsager.github.io/imdbench/sql.html</a>
B very careful with json and postgressjs, there are strange bugs. Also there are various gotchas on the edges with typescript. AFAIK the code uses a lot of regex and that breaks json in particular.