TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PostgresJs: PostgreSQL client for Node.js and Deno

308 pointsby jerawaj749over 1 year ago

30 comments

lolovaldezover 1 year ago
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.
评论 #37883205 未加载
评论 #37885121 未加载
评论 #37890334 未加载
评论 #37887401 未加载
Rapzidover 1 year ago
This library is proper fast. Don&#x27;t get distracted comparing this to other libraries just on the basis of similar string template syntax; it doesn&#x27;t have a dependency on pg because it implements its own low level client.<p>I&#x27;ve built systems on this loading multiple 10k records at time and it crushes.
评论 #37886254 未加载
dangover 1 year ago
Related:<p><i>Show HN: Postgres.js – Fastest Full-Featured PostgreSQL Client for Node and Deno</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30794332">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30794332</a> - March 2022 (83 comments)<p><i>Show HN: Postgres.js – Fast PostgreSQL Client for Node.js</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21864245">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21864245</a> - Dec 2019 (12 comments)
terrapluraover 1 year ago
Perhaps not as featured as OP’s but I’ve found <a href="https:&#x2F;&#x2F;pgtyped.dev&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;pgtyped.dev&#x2F;</a> useful. Queries are written as SQL files, and pgtyped creates typed functions you call with query parameters.
评论 #37884816 未加载
porsagerover 1 year ago
Author here. Worth noting is that Cloudflare is now also supported :)
评论 #37888437 未加载
pyrolisticalover 1 year ago
I like how it has zero deps
评论 #37884457 未加载
noduermeover 1 year ago
&gt;&gt; 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&#x27;s an interesting but highly opinionated approach...
评论 #37879690 未加载
评论 #37879650 未加载
skrebbelover 1 year 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: <a href="https:&#x2F;&#x2F;jawj.github.io&#x2F;zapatos&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;jawj.github.io&#x2F;zapatos&#x2F;</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.
评论 #37879825 未加载
评论 #37879505 未加载
评论 #37879992 未加载
评论 #37902297 未加载
qwertoxover 1 year ago
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.
评论 #37879656 未加载
surprisetalkover 1 year ago
Postgres.js is one of the best libraries I’ve ever used!<p>Its use of templating in JS is really intuitive.
fatih-erikliover 1 year ago
I like the idea of using tagged templates for sanitizing sql query inputs. Kudos
andrewstuartover 1 year ago
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.
评论 #37883782 未加载
collaborativeover 1 year ago
I use pg in Node and these results are impressive
pier25over 1 year ago
Used pg for years then migrated to postgres.js about two years ago. I love it and have had zero issues.
foreignerover 1 year ago
Shout out to <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;sql-template-strings" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;sql-template-strings</a>, which does a similar template string SQL escaping standalone.
评论 #37881707 未加载
评论 #37883617 未加载
jasfiover 1 year ago
The benchmarks linked to don&#x27;t compare PostgresJs to Prisma. That would be useful.<p>Also the link text (Fastest full-featured node &amp; deno client) should include the word benchmark, for those looking for one.
评论 #37883401 未加载
评论 #37881568 未加载
sheatonover 1 year ago
Also see: <a href="https:&#x2F;&#x2F;github.com&#x2F;gajus&#x2F;slonik">https:&#x2F;&#x2F;github.com&#x2F;gajus&#x2F;slonik</a>
评论 #37879838 未加载
评论 #37885671 未加载
rco8786over 1 year ago
The demo gif is fabulous.
评论 #37881571 未加载
christophilusover 1 year ago
This is a great library. I’ve been using it in production for a while (since 2019, IIRC). No complaints.
sam_goodyover 1 year ago
Been using pg-promise[1] for years (for Node). How does this compare - is there a reason to switch?<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;vitaly-t&#x2F;pg-promise">https:&#x2F;&#x2F;github.com&#x2F;vitaly-t&#x2F;pg-promise</a>
评论 #37892270 未加载
hestefiskover 1 year ago
Looks neat. Is there a table generation &#x2F; migration library included?
评论 #37881457 未加载
Coxaover 1 year ago
Super happy user of this [1] it&#x27;s rather minimalistic but great.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;Ff00ff&#x2F;mammoth">https:&#x2F;&#x2F;github.com&#x2F;Ff00ff&#x2F;mammoth</a>
brapover 1 year ago
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(‘…’).
评论 #37881094 未加载
评论 #37881084 未加载
评论 #37884083 未加载
jzigover 1 year ago
I wonder if this (or Zapatos) could replace Supabase’s postgrest-js, or how it compares.
评论 #37880450 未加载
iddanover 1 year ago
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:&#x2F;&#x2F;www.prisma.io&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.prisma.io&#x2F;</a>
评论 #37880174 未加载
评论 #37881115 未加载
wg0over 1 year ago
What will it take for it to run directly in browser?
评论 #37882738 未加载
评论 #37884123 未加载
joshxyzover 1 year ago
reposting my comment on its benchmarks:<p>On what makes it postgres.js faster, from author himself:<p>&gt; it seems Postgres.js is actually faster than, not only pg, but of any driver out-there<p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;porsager&#x2F;postgres&#x2F;discussions&#x2F;627">https:&#x2F;&#x2F;github.com&#x2F;porsager&#x2F;postgres&#x2F;discussions&#x2F;627</a><p>- <a href="https:&#x2F;&#x2F;porsager.github.io&#x2F;imdbench&#x2F;sql.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;porsager.github.io&#x2F;imdbench&#x2F;sql.html</a>
评论 #37880882 未加载
评论 #37880437 未加载
评论 #37883260 未加载
评论 #37882393 未加载
somecommitover 1 year ago
please consider sequelize, I&#x27;m an old developer and I don&#x27;t miss at all writing sql statement
hhfdsbvcover 1 year ago
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.
评论 #37881325 未加载
评论 #37884291 未加载
评论 #37890361 未加载
gavinrayover 1 year ago
[flagged]
评论 #37883065 未加载
评论 #37881078 未加载
评论 #37881102 未加载
评论 #37881004 未加载
评论 #37881076 未加载