pg-named

1.0.3 • Public • Published

pg-named

Named parameters for node-postgres. Kudos to: https://github.com/bwestergard/node-postgres-named and the refactored https://github.com/jars/node-postgres-named.

Before:

client.query('SELECT name FROM person WHERE name = $1 AND tenure <= $2 AND age <= $3', ['Ursus', 2.5, 24]).then(console.log);

After:

client.query('SELECT name FROM person WHERE name = :name AND tenure <= :tenure AND age <= :age', {'name': 'Ursus', 'tenure': 2.5, 'age': 24}).then(console.log);

Placeholders must begin with : or $ and can contain only alphanumerics, underscores, and dashes.

Usage

import pg from 'pg';
import pgNamed from 'pg-named';

pgNamed(pg);

Readme

Keywords

none

Package Sidebar

Install

npm i pg-named

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

7.85 kB

Total Files

5

Last publish

Collaborators

  • damianobarbati