postgres
4.1.1 · 11 Nov 2026Unlicense38.9M / weekRepositoryHomepagenpmAtom feed
3.4.9 is the newest release of 3.x.
In short
14 breaking1 new11 changed
- Breaking
There are a few breaking changes from v2 beta, which some (myself included) was using in production, so I'm skipping a stable v2 release and going straight to v3.
- Breaking
Cursors are always called with
Resultarrays (previously cursor 1 would return a row object, where > 1 would return an array of rows) - Breaking
.writable()and.readable()is now async (returns a Promise that resolves to the stream) - Breaking
Queries now returns a lazy promise instead of being executed immediately. This means the query won't be sent until awaited (.then, .catch, .finally is called) or until
.execute()is manually called. - Breaking
.stream()is renamed to.forEach - Breaking
Returned results are now it's own
Resultclass extendingArrayinstead of an Array with extra properties (actually shouldn't be breaking unless you're doing something funny) - Breaking
Parameters are now cast using the types returned from Postgres ParameterDescription with a fallback to the previously inferred types
- Breaking
Only tested with node v12 and up
Release note
This is a complete rewrite to better support all the features that I was trying to get into v2. There are a few breaking changes from v2 beta, which some (myself included) was using in production, so I'm skipping a stable v2 release and going straight to v3.
Here are some of the new things available, but check the updated docs.
Dynamic query builder based on raw sql
Realtime subscribe to db changes through logical replication
Multi-host support for High Availability setups
Postgres input parameter types from
ParameterDescriptionDeno support
Cursors as async iterators
.describe()to only get query input types and column definitionsSupport for Large Objects
max_lifetimefor connectionsCancellation of requests
Converted to ESM (with CJS support)
Typescript support (Credit @minigugus)
Breaking changes from v2 -> v3
- Breaking
Cursors are always called with
Resultarrays (previously cursor 1 would return a row object, where > 1 would return an array of rows) - Breaking
.writable()and.readable()is now async (returns a Promise that resolves to the stream) - Breaking
Queries now returns a lazy promise instead of being executed immediately. This means the query won't be sent until awaited (.then, .catch, .finally is called) or until
.execute()is manually called. - Breaking
.stream()is renamed to.forEach - Breaking
Returned results are now it's own
Resultclass extendingArrayinstead of an Array with extra properties (actually shouldn't be breaking unless you're doing something funny) - Breaking
Parameters are now cast using the types returned from Postgres ParameterDescription with a fallback to the previously inferred types
- Breaking
Only tested with node v12 and up
- Breaking
Implicit array value to multiple parameter expansion removed (use sql([...]) instead)
Breaking changes from v1 -> v2 (v2 never moved on from beta)
- Breaking
All identifiers from
sql()in queries are now always quoted - Breaking
Undefined parameters are no longer allowed
- Breaking
Rename timeout option to
idle_timeout - Breaking
Default to 10 connections instead of number of CPUs
- Breaking
Numbers that cannot be safely cast to JS Number are returned as string. This happens for eg,
select count(*)becausecount()returns a 64 bit integer (int8), so if you know yourcount()won't be too big for a js number just cast in your query to int4 likeselect count(*)::int
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.