https://github.com/kriasoft/node-pg-client
Promise-based wrapper for `node-postgres` library designed for easy use with ES7 async/await.
https://github.com/kriasoft/node-pg-client
Last synced: about 1 month ago
JSON representation
Promise-based wrapper for `node-postgres` library designed for easy use with ES7 async/await.
- Host: GitHub
- URL: https://github.com/kriasoft/node-pg-client
- Owner: kriasoft
- License: mit
- Created: 2016-02-22T01:41:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-28T02:40:29.000Z (almost 4 years ago)
- Last Synced: 2025-05-06T23:02:41.503Z (about 1 month ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ES7 Async/Await Client for PostgreSQL
[](https://www.npmjs.com/package/pg-client)
[](https://www.npmjs.com/package/pg-client)
[](https://travis-ci.org/kriasoft/node-pg-client)
[](https://david-dm.org/kriasoft/node-pg-client)
[](https://david-dm.org/kriasoft/node-pg-client#info=devDependencies)> Promise-based wrapper for [node-postgres](https://github.com/brianc/node-postgres)
> library designed for easy use with ES7 async/await.### How to Install
```
$ npm install pg-client --save
```### Getting Started
Usage sample in a Node.js/Express web app:
```js
import db from 'pg-client';
import { Router } from 'express';
import { connectionString } from '../config';const router = new Router();
router.get('/users', (req, res, next) => {
db.connect(connectionString, async ({ query }) => {
const result = await query('SELECT id, email FROM users WHERE id = $1', 123);
if (result.rowCount) {
res.send(result.rows[0]);
} else {
res.sendStatus(404);
}
}).catch(next);
});export default router;
```### Related Projects
* [Membership Database](https://github.com/membership/membership.db) — SQL database schema boilerplate for building web apps
* [React Starter Kit](https://github.com/kriasoft/react-starter-kit) — Isomorphic web app boilerplate### License
The MIT License © 2016 Kriasoft, LLC. All rights reserved. Made with ♥ by
Konstantin Tarkus ([@koistya](https://twitter.com/koistya)) and
[contributors](https://github.com/kriasoft/node-pg-client/graphs/contributors)