https://github.com/snorkypie/node-postgres-named-function-arguments
Named function arguments for node-postgres
https://github.com/snorkypie/node-postgres-named-function-arguments
node node-js node-postgres nodejs postgres postgresql postgresql-database
Last synced: 2 months ago
JSON representation
Named function arguments for node-postgres
- Host: GitHub
- URL: https://github.com/snorkypie/node-postgres-named-function-arguments
- Owner: snorkypie
- License: mit
- Created: 2019-07-24T18:05:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-25T11:53:41.000Z (over 6 years ago)
- Last Synced: 2025-10-11T21:49:35.895Z (4 months ago)
- Topics: node, node-js, node-postgres, nodejs, postgres, postgresql, postgresql-database
- Language: JavaScript
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
node-postgres-named-function-arguments
===================
[](https://travis-ci.org/snorkypie/node-postgres-named-function-arguments)
[](https://badge.fury.io/js/node-postgres-named-function-arguments)
Named function arguments for node-postgres
Install with [npm](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com/):
```bash
# 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
```
## Usage
```javascript
import nfa from 'node-postgres-named-function-arguments';
client.query(...nfa('get_user', { _username: 'snorkypie' }));
```
and
```javascript
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...
```javascript
client.query('select * from get_user(_username := $1)', [ 'snorkypie' ]);
```
## Rationale
This package solves two major problems with a lot of the solutions out there.
1. Target a specific overloaded function
2. Target specific arguments where default values are used