Provides large object support for PostgreSQL clients using the 'postgres' npm package. Current stable version is 1.0.5. It allows streaming of large binary objects (LOBs) to and from PostgreSQL, implementing the PostgreSQL large object API. Key differentiators: lightweight, zero dependencies beyond 'postgres', TypeScript types included, and designed for the modern 'postgres' client (not 'pg'). Suitable for storing and retrieving files, images, or any large binary data in PostgreSQL.
npm install postgres-large-objectNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create, write to, and read from a PostgreSQL large object using the postgres-large-object library with ESM imports.
Upgrade to Node.js 14+ and use ESM imports (import/export) instead of require().
Switch from 'pg' to 'postgres' client (the newer, modern PostgreSQL client for Node.js).
Pass { sql: yourPostgresClientInstance } instead of { pg: ... } or a connection string.Ensure the 'sql' client is kept alive until all streams are fully consumed.
Await all LargeObject methods like .read(), .write(), .tell(), etc.
Use ESM: import { LargeObjectManager } from 'postgres-large-object'Install and use the 'postgres' client (npm install postgres) and pass { sql: postgresClient } to LargeObjectManager.Ensure the OID is from a previously created large object and is a number (not a string).
Instantiate with: new LargeObjectManager({ sql: yourPostgresInstance })