Slim Node Postgres is a lightweight PostgreSQL database abstraction layer for Node.js that simplifies connection pooling and prepared statements. Version 4.0.1 provides a promise-based API with methods like query, execute, insert, getOne, getValue, and exists. It uses named parameters with @ syntax and returns typed results. Compared to raw pg or ORMs like Sequelize/TypeORM, it offers minimal overhead and easy setup for projects that need a simple, pool-managed client without full ORM features. Release cadence is sporadic; it has TypeScript definitions built in. Requires pg and its types as peer dependencies.
npm install slim-node-postgresNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to initialize SlimNodePostgres with a connection string, perform queries with named parameters, insert using the convenient insert method, and check for existence using the exists method.
Update to use @param syntax as documented; no manual $N replacement needed.
Always pass connection string or options object to the constructor.
Sanitize or whitelist table/column names before passing to insert.
Call db.close() in shutdown hooks to avoid hanging connections.
Use insert() for inserts to get proper insertId behavior.
Run 'npm install pg'
Ensure connection string is provided and db.connect() or first query is awaited
Update pg to >=8.0 and ensure slim-node-postgres is latest