Named function arguments for node-postgres
# via npm
$ npm install node-postgres-named-function-arguments
# via yarn (automatically saves the package to your `dependencies` in package.json)
$ yarn add node-postgres-named-function-arguments
import nfa from 'node-postgres-named-function-arguments';
client.query(...nfa('get_user', { _username: 'snorkypie' }));
and
var nfa = require('node-postgres-named-function-arguments');
var sql = nfa('get_user', { _username: 'snorkypie' });
client.query(sql[0], sql[1]);
would be the same as...
client.query('select * from get_user(_username := $1)', [ 'snorkypie' ]);
This package solves two major problems with a lot of the solutions out there.
- Target a specific overloaded function
- Target specific arguments where default values are used