{"library":"node-postgres-named","title":"Named Parameters for Node-Postgres","description":"node-postgres-named is a utility library designed to introduce named parameter support to the `node-postgres` client by monkeypatching its `query` method. As of its latest release, version 2.4.1 (published in 2018), this package allows developers to write more readable SQL queries using `$name` syntax, which it then translates into the positional `$1`, `$2` parameters required by PostgreSQL. This addresses a deliberate design choice in `node-postgres` to maintain a minimal API consistent with PostgreSQL's native capabilities, which do not inherently support named parameters. Given the absence of updates since 2018, this project is considered abandoned. Consequently, its compatibility with contemporary Node.js versions, recent `node-postgres` releases, and modern JavaScript module systems like ESM is highly uncertain and likely problematic.","language":"javascript","status":"abandoned","last_verified":"Sat Apr 25","install":{"commands":["npm install node-postgres-named"],"cli":null},"imports":["const named = require('node-postgres-named');","named.patch(client);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const pg = require('pg');\nconst named = require('node-postgres-named');\n\nconst conString = process.env.DATABASE_URL || 'postgres://user:password@host:5432/database';\n\nasync function runQuery() {\n  const client = new pg.Client(conString);\n  named.patch(client); // Patch the client instance in-place\n\n  try {\n    await client.connect();\n\n    const query = {\n      text: 'SELECT name FROM person WHERE name = $name AND tenure <= $tenure AND age <= $age',\n      values: { 'name': 'Ursus', 'tenure': 2.5, 'age': 24 }\n    };\n\n    const res = await client.query(query);\n    console.log('Query result:', res.rows);\n  } catch (err) {\n    console.error('Error executing query', err.stack);\n  } finally {\n    await client.end();\n  }\n}\n\nrunQuery();","lang":"javascript","description":"This quickstart demonstrates how to import, patch a `pg` client, and then execute a query using named parameters.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}