A lightweight, class-based query system for PostgreSQL using the pg library. Current stable version is 1.0.3-beta. It provides a structured approach to organize SQL queries as reusable classes with named queries for prepared statements, built-in error handling via safeRawCall, and utility helpers for common transformations. Key differentiators include a focus on type safety through JSDoc, a simple API with DB class for pool management and query execution, and a strong opinion on project structure.
npm install lapiz-postgresNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define a query class and execute it using DB with pool configuration.
Use require() and avoid ES import statements for this package.
Run npm install -D @types/pg to get types for pg Pool and PoolClient.
Pass individual query objects as separate arguments: new DB(config, query1, query2, ...)
Use descriptive and unique names for each query.
Destructure with defaults: const { result, database_error, unexpected_error } = await this.safeRawCall(pool, params);Use const DB = require('lapiz-postgres/db');Ensure each Query instance has a unique name in its super() call.
Ensure you pass a Pool instance (not PoolClient) to the DB constructor or .exec().