Registry / database / chaingres

chaingres

JSON →
library0.2.0jsnpmunverified

Chaingres is a query builder for PostgreSQL that uses a cascading (chained) style programming API. Version 0.2.0 is the latest stable release, but the project appears to be in early development with minimal updates. It wraps the 'pg' Node.js driver. Key differentiator: chainable methods for constructing INSERT and SELECT queries, similar to jQuery-style chaining. However, it lacks TypeScript support, modern ESM exports, and comprehensive documentation. Alternatives like Knex.js or Slonik offer more features, maturity, and active maintenance.

npm install chaingres
INSTALL
IMPORT
SIG · CHAINGRES
C
chaingres
databasejavascriptv0.2.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.

chaingres
const chaingres = require('chaingres');
import chaingres from 'chaingres';
This package uses CommonJS (require). There is no default ESM export. Attempting to import as ES module will fail.
new(client)
chaingres.new(client).insert({...})
chaingres(client).insert({...})
The API requires calling .new(client) first. Directly calling chaingres(client) is not supported.
then(function(err, result))
.then(function(err, result) { ... })
.then(result => { ... })
The then callback expects both err and result arguments, not just result. It does not return a standard Promise.

Connects to a PostgreSQL database using 'pg' client and performs an INSERT query using the Chaingres chainable API without Promises.

const pg = require('pg'); const chaingres = require('chaingres'); const client = new pg.Client({ user: process.env.PGUSER ?? 'postgres', host: process.env.PGHOST ?? 'localhost', database: process.env.PGDATABASE ?? 'test', password: process.env.PGPASSWORD ?? '', port: process.env.PGPORT ?? 5432 }); client.connect(err => { if (err) throw err; chaingres .new(client) .insert({ 'name': 'John', 'email': 'john@example.com' }) .then(function(err, result) { if (err) throw err; console.log('Insert successful', result); client.end(); }); });
Debug
Known issues
gotchaThe .then() method does not return a native Promise. It expects a callback with (err, result) and returns undefined.
fix
Use the provided .then() with two arguments, or wrap in a Promise manually if needed.
affects: <=0.2.0
gotchaPackage is in very early stage (v0.2.0). No TypeScript definitions, no testing framework, and minimal documentation.
fix
Consider using a more mature query builder like Knex.js for production use.
affects: <=0.2.0
gotchaNo error handling for missing client object. Calling chaingres.new() without a valid client will cause a runtime error.
fix
Always pass a connected 'pg.Client' instance to .new().
affects: <=0.2.0
Errors
Common errors & fixes
chaingres(...).new is not a function
Importing chaingres as default instead of using require and then calling .new incorrectly.
fix
Use const chaingres = require('chaingres'); and then chaingres.new(client) correctly.
Cannot read property 'then' of undefined
Calling .new() or query methods without providing a valid client or missing required parameters.
fix
Ensure you call .new(client) with a valid pg.Client instance before chaining other methods.
TypeError: chaingres.default is not a function
Attempting ES module import with `import chaingres from 'chaingres'` on a CJS-only package.
fix
Use CommonJS require: const chaingres = require('chaingres');
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
pgrequiredChaingres builds and executes queries using the 'pg' PostgreSQL client. It is a runtime peer dependency.
Agent activity
9 hits · last 30 days
node
6
OpenAI (training)
1
Resources