{"id":44113,"library":"voicer-pg-lib","title":"Voicer Postgres Library","description":"Custom library developed by Voicer for interacting with PostgreSQL databases. Current stable version is 2.1.3. Provides a simplified wrapper around the `pg` (node-postgres) driver for common database operations like querying and connection management using environment variables. Designed for internal use within Voicer projects; not actively maintained for public adoption. Release cadence is low, with updates tied to internal needs. Key differentiator: opinionated setup via .env variables, reducing boilerplate for Voicer's infrastructure. Note: the library is not published on npm (only available via GitHub), and usage is strictly for PostgreSQL without ORM features.","status":"active","version":"2.1.3","language":"javascript","source_language":"en","source_url":"git@github.com:VoicerBr/pgLib","tags":["javascript"],"install":[{"cmd":"npm install voicer-pg-lib","lang":"bash","label":"npm"},{"cmd":"yarn add voicer-pg-lib","lang":"bash","label":"yarn"},{"cmd":"pnpm add voicer-pg-lib","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Direct dependency for PostgreSQL client connections and queries","package":"pg","optional":false},{"reason":"Used to load database configuration from .env file","package":"dotenv","optional":true}],"imports":[{"note":"Supports ESM and CJS; named export.","wrong":"const query = require('voicer-pg-lib').query","symbol":"query","correct":"import { query } from 'voicer-pg-lib'"},{"note":"Instance of pg.Pool configured via environment variables; use carefully with concurrent operations.","wrong":"import pool from 'voicer-pg-lib'/pool","symbol":"pool","correct":"import { pool } from 'voicer-pg-lib'"},{"note":"Returns promise resolving to true/false; ESM only in v2.","wrong":"const { checkConnection } = require('voicer-pg-lib'","symbol":"checkConnection","correct":"import { checkConnection } from 'voicer-pg-lib'"}],"quickstart":{"code":"import { query, pool } from 'voicer-pg-lib';\n\nasync function main() {\n  try {\n    const res = await query('SELECT NOW()', []);\n    console.log('Current time:', res.rows[0].now);\n    \n    const client = await pool.connect();\n    const result = await client.query('SELECT $1::text as name', ['Voicer']);\n    console.log('Name:', result.rows[0].name);\n    client.release();\n  } catch (err) {\n    console.error('Database error:', err);\n  }\n}\n\nmain();","lang":"typescript","description":"Shows basic query execution and connection pooling using voicer-pg-lib with environment variables for configuration."},"warnings":[{"fix":"Update imports to use named exports: `import { query } from 'voicer-pg-lib'` instead of `import pgLib from 'voicer-pg-lib'`.","message":"Library renamed or restructured in v2.0.0: exports changed from default to named exports.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure .env file is loaded before importing (e.g., with dotenv) or set environment variables in runtime.","message":"Environment variables PG_USER, PG_PASSWORD, PG_DATABASE, PG_HOST, PG_PORT are required and must be set before importing the library.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `query` function for single queries; for complex transactions, acquire a client from `pool` and release it promptly.","message":"The `pool` export is a singleton; creating multiple pools may lead to connection limit issues.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Install @types/pg for type hints, but custom types may be needed for query results.","message":"Library does not support TypeScript types; all types are `any`.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.1.3':18 'activ':50 'adopt':54 'around':23 'avail':87 'boilerpl':73 'cadenc':56 'common':31 'connect':37 'current':14 'custom':4 'databas':13,32 'design':42 'develop':6 'differenti':66 'driver':29 'env':70 'environ':40 'featur':98 'github':89 'infrastructur':77 'interact':10 'intern':44,63 'javascript':99 'key':65 'librari':3,5,80 'like':34 'low':58 'maintain':51 'manag':38 'need':64 'node':27 'node-postgr':26 'note':78 'npm':85 'oper':33 'opinion':67 'orm':97 'pg':25 'postgr':2,28 'postgresql':12,95 'project':48 'provid':19 'public':53 'publish':83 'queri':35 'reduc':72 'releas':55 'setup':68 'simplifi':21 'stabl':15 'strict':93 'tie':61 'updat':60 'usag':91 'use':39,45 'variabl':41,71 'version':16 'via':69,88 'voicer':1,8,47,75 'within':46 'without':96 'wrapper':22","created_at":"2026-06-05T17:03:02.833227+00:00","updated_at":"2026-06-05T17:03:02.833227+00:00","problems":[{"fix":"Check PG_HOST and PG_PORT values; ensure database server accepts connections from your IP.","cause":"Database host unreachable or wrong port/host in .env","error":"Error: connect ETIMEDOUT"},{"fix":"Verify .env file has correct credentials; ensure user exists and has correct permissions.","cause":"Wrong PG_USER or PG_PASSWORD in .env","error":"Error: password authentication failed for user ..."},{"fix":"Use `import { query } from 'voicer-pg-lib'` (ESM) or `const { query } = require('voicer-pg-lib')` (CJS).","cause":"Using CommonJS require incorrectly or import from wrong path","error":"TypeError: Cannot destructure property 'query' of ..."},{"fix":"Create the database or update .env with an existing database name.","cause":"PG_DATABASE environment variable set to a database that doesn't exist","error":"Error: database ... does not exist"}],"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":"git@github.com:VoicerBr/pgLib","github":"git@github.com:VoicerBr/pgLib","docs":null,"changelog":null,"pypi":null,"npm":"voicer-pg-lib","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","devops"],"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}}