Registry / database / unconventional-pg-queries

unconventional-pg-queries

JSON →
library1.8.0jsnpmunverified

A lightweight PostgreSQL query builder for Node.js, optimized for edge environments like Cloudflare Workers. Version 1.8.0 (stable, actively maintained). Builds SQL queries using plain JavaScript objects with full TypeScript type safety. Supports relation expansion, nested JSON field queries, cursor-based pagination, and relation filtering. Minimal dependencies (only pg), making it ideal for size-constrained deployments. Differentiates from heavier ORMs by its small bundle size and simplicity.

npm install unconventional-pg-queries
INSTALL
IMPORT
SIG · UNCONVENTIONAL-PG-
U
unconventional-pg-queries
databasejavascriptv1.8.0
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.

createClient
✓ import { createClient } from 'unconventional-pg-queries'
✗ const createClient = require('unconventional-pg-queries').createClient
Package uses ESM exports. For CommonJS, use dynamic import or the .cjs bundle.
query
✓ import { query } from 'unconventional-pg-queries'
✗ import query from 'unconventional-pg-queries'
query is a named export, not default.
UnconventionalClient
✓ import type { UnconventionalClient } from 'unconventional-pg-queries'
✗ import { UnconventionalClient } from 'unconventional-pg-queries'
UnconventionalClient is a TypeScript type, not a runtime value. Use type import to avoid bundling issues.

Creates a client from a connection string, then queries the 'users' table with a WHERE LIKE filter, selecting specific columns and limiting to 10 rows.

import { createClient } from 'unconventional-pg-queries'; const client = createClient({ connectionString: process.env.DATABASE_URL ?? 'postgres://user:pass@localhost:5432/db', }); const result = await client.query('users') .where({ name: { $like: '%Alice%' } }) .select(['id', 'name', 'email']) .limit(10); console.log(result.rows);
Debug
Known issues
gotchaThe query builder does not support JOINs directly; use relation expansion with 'expand' option instead.
fix
Use the 'expand' property in the query object to include related data, e.g., query('posts').expand({ author: true }).
affects: <2.0
breakingIn version 1.x, the 'createClient' function requires a 'pool' option instead of a 'connectionString'. Future versions may change this.
fix
Use the pool option: createClient({ pool: new pg.Pool({ connectionString }) }).
affects: >=1.0 <2.0
deprecatedThe 'sort' option in queries is deprecated; use 'orderBy' instead.
fix
Replace sort: { field: 'asc' } with orderBy: { field: 'asc' }.
affects: >=1.5 <2.0
Errors
Common errors & fixes
Cannot use import statement outside a module
Package is ESM-only; CommonJS projects need to use dynamic import or enable ESM.
fix
Use dynamic import: const { createClient } = await import('unconventional-pg-queries');
TypeError: client.query is not a function
Client was not properly created using createClient() or using incorrect import.
fix
Ensure you import { createClient } and call it to get the client instance, then use client.query('table').
UnconventionalClient is not a constructor
Importing UnconventionalClient as a value instead of a type.
fix
Use import type { UnconventionalClient } from 'unconventional-pg-queries';
Upgrade
Version history
1.8.0latest on npm
Audit
Dependencies
pgrequiredPeer dependency: the native PostgreSQL client used for query execution.
Agent activity
21 hits · last 30 days
node
16
Meta
1
OpenAI (training)
1
Resources
unconventional-pg-queries — npm install unconventional-pg-queries · libregistry