Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goenning/pg-run
pg-run is a thin and fast wrapper around node-postgres with a sync-like API
https://github.com/goenning/pg-run
Last synced: 28 days ago
JSON representation
pg-run is a thin and fast wrapper around node-postgres with a sync-like API
- Host: GitHub
- URL: https://github.com/goenning/pg-run
- Owner: goenning
- Created: 2015-10-06T00:42:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-06T11:49:35.000Z (over 9 years ago)
- Last Synced: 2024-11-02T19:41:36.433Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 152 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
###Work is still in progress!
[![Build Status](https://travis-ci.org/goenning/pg-run.svg?branch=master)](https://travis-ci.org/goenning/pg-run)
#pg-run
`pg-run` is a thin and fast wrapper around [node-postgres](https://github.com/brianc/node-postgres) with a `sync-like` API.
```
var pg = require('pg-run')(require('pg'))pg.connString = ''
pg(function*() {
yield pg.query('CREATE TEMP TABLE foo(id serial, name varchar(50))')
yield pg.query('INSERT INTO foo VALUES (1, \'John\')')
yield pg.query('INSERT INTO foo VALUES (2, \'Bob\')')var result = yield pg.query('SELECT COUNT(*)::int as count FROM foo')
console.log(result.rows);
})
```###ES6 is mandatory! (Node v4.0.0+)
This project is highly based on [No promises: asynchronous JavaScript with only generators](http://www.2ality.com/2015/03/no-promises.html)