{"id":42496,"library":"chaingres","title":"Chaingres","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/ChrisCates/chaingres","tags":["javascript","Chris","Cates","Chaingres","Postgres","Unchained"],"install":[{"cmd":"npm install chaingres","lang":"bash","label":"npm"},{"cmd":"yarn add chaingres","lang":"bash","label":"yarn"},{"cmd":"pnpm add chaingres","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Chaingres builds and executes queries using the 'pg' PostgreSQL client. It is a runtime peer dependency.","package":"pg","optional":false}],"imports":[{"note":"This package uses CommonJS (require). There is no default ESM export. Attempting to import as ES module will fail.","wrong":"import chaingres from 'chaingres';","symbol":"chaingres","correct":"const chaingres = require('chaingres');"},{"note":"The API requires calling .new(client) first. Directly calling chaingres(client) is not supported.","wrong":"chaingres(client).insert({...})","symbol":"new(client)","correct":"chaingres.new(client).insert({...})"},{"note":"The then callback expects both err and result arguments, not just result. It does not return a standard Promise.","wrong":".then(result => { ... })","symbol":"then(function(err, result))","correct":".then(function(err, result) { ... })"}],"quickstart":{"code":"const pg = require('pg');\nconst chaingres = require('chaingres');\n\nconst client = new pg.Client({\n  user: process.env.PGUSER ?? 'postgres',\n  host: process.env.PGHOST ?? 'localhost',\n  database: process.env.PGDATABASE ?? 'test',\n  password: process.env.PGPASSWORD ?? '',\n  port: process.env.PGPORT ?? 5432\n});\n\nclient.connect(err => {\n  if (err) throw err;\n\n  chaingres\n    .new(client)\n    .insert({\n      'name': 'John',\n      'email': 'john@example.com'\n    })\n    .then(function(err, result) {\n      if (err) throw err;\n      console.log('Insert successful', result);\n      client.end();\n    });\n});","lang":"javascript","description":"Connects to a PostgreSQL database using 'pg' client and performs an INSERT query using the Chaingres chainable API without Promises."},"warnings":[{"fix":"Use the provided .then() with two arguments, or wrap in a Promise manually if needed.","message":"The .then() method does not return a native Promise. It expects a callback with (err, result) and returns undefined.","severity":"gotcha","affected_versions":"<=0.2.0"},{"fix":"Consider using a more mature query builder like Knex.js for production use.","message":"Package is in very early stage (v0.2.0). No TypeScript definitions, no testing framework, and minimal documentation.","severity":"gotcha","affected_versions":"<=0.2.0"},{"fix":"Always pass a connected 'pg.Client' instance to .new().","message":"No error handling for missing client object. Calling chaingres.new() without a valid client will cause a runtime error.","severity":"gotcha","affected_versions":"<=0.2.0"}],"env_vars":null,"search_vec":"'0.2.0':18 'activ':79 'altern':69 'api':16 'appear':27 'builder':6 'cascad':12 'cate':83 'chain':13,57 'chainabl':44 'chaingr':1,2,84 'chris':82 'comprehens':67 'construct':47 'develop':32 'differenti':43 'document':68 'driver':41 'earli':31 'esm':64 'export':65 'featur':76 'howev':58 'insert':48 'javascript':81 'jqueri':55 'jquery-styl':54 'key':42 'knex.js':71 'lack':60 'latest':21 'like':70 'mainten':80 'matur':77 'method':45 'minim':34 'modern':63 'node.js':40 'offer':74 'pg':39 'postgr':85 'postgresql':8 'program':15 'project':26 'queri':5,51 'releas':23 'select':50 'similar':52 'slonik':73 'stabl':22 'style':14,56 'support':62 'typescript':61 'unchain':86 'updat':35 'use':10 'version':17 'wrap':37","created_at":"2026-06-05T16:55:16.673712+00:00","updated_at":"2026-06-05T16:55:16.673712+00:00","problems":[{"fix":"Use const chaingres = require('chaingres'); and then chaingres.new(client) correctly.","cause":"Importing chaingres as default instead of using require and then calling .new incorrectly.","error":"chaingres(...).new is not a function"},{"fix":"Ensure you call .new(client) with a valid pg.Client instance before chaining other methods.","cause":"Calling .new() or query methods without providing a valid client or missing required parameters.","error":"Cannot read property 'then' of undefined"},{"fix":"Use CommonJS require: const chaingres = require('chaingres');","cause":"Attempting ES module import with `import chaingres from 'chaingres'` on a CJS-only package.","error":"TypeError: chaingres.default is not a function"}],"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":"https://github.com/ChrisCates/chaingres#readme","github":"https://github.com/ChrisCates/chaingres","docs":null,"changelog":null,"pypi":null,"npm":"chaingres","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"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}}