A wrapper for node-postgres (pg) that provides promise-based methods (e.g., connectPromise, queryPromise) compatible with the co generator-based control flow library and async/await. Current version 2.0.2, last updated in 2022. It allows using PostgreSQL connections and queries with yield or await instead of callbacks, without altering the original pg API. Supports pg, pg-native, and pg-pure backends. The library is in maintenance mode; newer projects should prefer native async/await with pg directly.
npm install co-pgNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to PostgreSQL using co-pg with co, querying, and closing connection.
Replace co-pg with native pg promises: const { Pool } = require('pg'); const pool = new Pool(); await pool.query(...);Upgrade to 2.0.0 or later, or use async/await directly with co-pg (though co itself is outdated).
Always call the done function returned from connectPromise after finishing with the client.
Use const pg = require('co-pg')(require('pg')); then access pg.Client.Run 'npm install co-pg'
Use const pg = require('co-pg')(require('pg'));Ensure pg = require('co-pg')(require('pg')) and use new pg.Client(...).