{"id":43543,"library":"pg-connect","title":"pg-connect","description":"Deprecated wrapper around node-postgres that provides a promise-based API for database connections and transactions, automatically releasing them via Bluebird's disposer pattern. Last version 2.0.2. Since pg@6 (2016), node-postgres natively supports promises, making this package obsolete. No longer maintained. Users should migrate to direct use of pg with async/await.","status":"deprecated","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/lanetix/node-pg-connect","tags":["javascript","pg","postgres","promise","connection","transaction"],"install":[{"cmd":"npm install pg-connect","lang":"bash","label":"npm"},{"cmd":"yarn add pg-connect","lang":"bash","label":"yarn"},{"cmd":"pnpm add pg-connect","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for PostgreSQL client","package":"pg","optional":false},{"reason":"Provides Promise.using and disposer pattern","package":"bluebird","optional":false}],"imports":[{"note":"This package is CommonJS only and returns a function that expects a connection string; ESM import will fail. Use require() for the factory.","wrong":"import getConnection from 'pg-connect'","symbol":"default","correct":"const getConnection = require('pg-connect')(connectionString)"},{"note":"withTransaction is a method on the factory's return value, not on the module. It requires a callback as argument.","wrong":"getConnection.withTransaction()","symbol":"withTransaction","correct":"getConnection.withTransaction(function(query) { ... })"},{"note":"end is on the factory instance, not on the module export.","wrong":"require('pg-connect').end()","symbol":"end","correct":"getConnection.end()"}],"quickstart":{"code":"const Promise = require('bluebird');\nconst getConnection = require('pg-connect')(process.env.DATABASE_URL ?? '');\n\nPromise.using(\n  getConnection(),\n  function (query) {\n    return query('SELECT NOW()')\n      .then(function(result) {\n        console.log(result.rows[0].now);\n      });\n  }\n).then(function() {\n  console.log('Connection released');\n}).catch(function(err) {\n  console.error(err);\n});","lang":"javascript","description":"Demonstrates creating a connection and running a simple query using Promise.using to auto-release."},"warnings":[{"fix":"Use pg directly with pg.Pool and async/await.","message":"Package is deprecated since pg@6 introduced native promise support.","severity":"deprecated","affected_versions":">=2.0.2"},{"fix":"Install bluebird and use it as the Promise implementation.","message":"Requires Bluebird for Promise.using — native Promise does not support .using.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"const getConnection = require('pg-connect')(connectionString);","message":"The module export is a factory function, not a connection instance. Call it with a connection string before use.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use require() or set type: 'commonjs' in package.json.","message":"Does not support ESM. Using import will throw an error.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.0.2':32 '2016':36 '6':35 'api':16 'around':6 'async/await':59 'automat':22 'base':15 'bluebird':26 'connect':3,19,64 'databas':18 'deprec':4 'direct':54 'dispos':28 'javascript':60 'last':30 'longer':48 'maintain':49 'make':43 'migrat':52 'nativ':40 'node':8,38 'node-postgr':7,37 'obsolet':46 'packag':45 'pattern':29 'pg':2,34,57,61 'pg-connect':1 'postgr':9,39,62 'promis':14,42,63 'promise-bas':13 'provid':11 'releas':23 'sinc':33 'support':41 'transact':21,65 'use':55 'user':50 'version':31 'via':25 'wrapper':5","created_at":"2026-06-05T17:00:18.150312+00:00","updated_at":"2026-06-05T17:00:18.150312+00:00","problems":[{"fix":"npm install bluebird and require('bluebird') before using pg-connect.","cause":"Native Promise does not have a .using method; Bluebird is required.","error":"Unhandled rejection: TypeError: Promise.using is not a function"},{"fix":"const getConnection = require('pg-connect')(connectionString);","cause":"The import was done without calling the factory with a connection string.","error":"TypeError: getConnection is not a function"},{"fix":"npm install pg","cause":"pg is a peer dependency not automatically installed.","error":"Error: Cannot find module 'pg'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/lanetix/node-pg-connect","github":"https://github.com/lanetix/node-pg-connect","docs":null,"changelog":null,"pypi":null,"npm":"pg-connect","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}