Registry / database / pg-camelcase

pg-camelcase

JSON →
library0.0.3jsnpmunverified

pg-camelcase is a lightweight utility (v0.0.3, no active release schedule) that monkey-patches the pg (node-postgres) library to automatically convert PostgreSQL result field names from snake_case to camelCase. It provides a simple `inject(pg)` function that returns an undo function, and a standalone `camelCase(str)` helper. Differentiators: minimal API, no dependencies, and reversible injection. However, the package is in an early, possibly abandoned state with no recent updates or TypeScript support.

npm install pg-camelcase
INSTALL
IMPORT
SIG · PG-CAMELCASE
P
pg-camelcase
databasejavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import pgCamelCase from 'pg-camelcase'
const pgCamelCase = require('pg-camelcase').default
Assume ESM via .mjs or package.json exports; actual import may vary since package is old. Check the lib's actual export.
inject
import { inject } from 'pg-camelcase'
Named export for the injection function.
camelCase
import { camelCase } from 'pg-camelcase'
Named export for the helper function.

Shows how to inject camelCase conversion into pg, use it, and revert.

import pg from 'pg'; import { inject } from 'pg-camelcase'; const revert = inject(pg); const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL ?? '', }); pool.query('SELECT 1 as "some_snake_case"', (err, res) => { if (err) throw err; console.log(res.rows[0].someSnakeCase); // 1 revert(); // deactivate camel casing }); pool.query('SELECT 1 as "some_snake_case"', (err, res) => { if (err) throw err; console.log(res.rows[0].some_snake_case); // 1 });
Debug
Known issues
gotchaMonkey-patches pg's internal prototype; may break with pg version updates.
fix
Pin pg version or consider alternative packages that use hooks.
affects: >=0.0.0
gotchaNo TypeScript definitions; causes 'any' type or errors in TS projects.
fix
Add a manual declaration file or use a type assertion.
affects: >=0.0.0
deprecatedPackage is essentially abandoned (last update years ago).
fix
Consider forking or using pg-format with custom row parser.
affects: >=0.0.0
gotchaDoes not handle nested objects; only top-level field names.
fix
Use a more comprehensive transformation if nested keys are needed.
affects: >=0.0.0
breakingInjection modifies pg globally; any subsequent queries across all clients are affected until revert() is called.
fix
Call revert() after each set of queries that need camelCase, or scope usage carefully.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: pgCamelCase.inject is not a function
Incorrect import style (CommonJS vs ESM).
fix
Use the correct import for your module system: const { inject } = require('pg-camelcase') for CJS.
Cannot find module 'pg-camelcase'
Package not installed or misspelled.
fix
Run npm install pg-camelcase and ensure name is correct.
TypeError: pg is not a function
Passing pg.Pool instead of the pg module itself to inject().
fix
Pass the entire pg module: inject(require('pg')).
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
pg-camelcase — npm install pg-camelcase · libregistry