1.2.3 • Published 10 years ago

billy-sql-postgres v1.2.3

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

billy-sql-postgres

Build Status NPM version

A Billy service that allows for executing queries against a PostgreSQL database.

Install

$ npm install billy-sql-postgres

Usage

var Application = require('billy');
var SqlService  = require('billy-sql-postgres');

var app = new Application();

app.service(SqlService);
app.config('postgres.url', 'posgres://user:pw@127.0.0.1:5432');

Use the sql dependency in any service or other injected objects:

app.service(function(sql) {
  sql.query('select * from widgets').then(function(rows) {
    ...
  });
});

Queries are all queued and executed via connections from the internal connection pool on the pg global object.

Injectables

New dependencies that you can use after adding this service:

tagtypedescriptionnotes
sqlPostgresFacadeThe generic SQL interfacePromise-based query interface

Configs

Available config properties:

configtypedescriptiondefault valuenotes
postgres.urlstringThe connection stringnullThe service will error out if not provided

Testing

$ npm test

License

MIT