UNPKG

pg-require-sql

Version:

Requires sql files and export functions for querying via pg

40 lines (32 loc) 1.15 kB
pg-require-sql ============== [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![Circle CI](https://circleci.com/gh/lanetix/node-pg-require-sql.svg?style=svg)](https://circleci.com/gh/lanetix/node-pg-require-sql) [![Dependency Status](https://david-dm.org/lanetix/node-pg-require-sql.svg)](https://david-dm.org/lanetix/node-pg-require-sql) 'Require' sql files for use with [pg-connect](https://www.npmjs.com/package/pg-connect). Installation ------------ [![npm install --save pg-require-sql](https://nodei.co/npm/pg-require-sql.png)](https://npmjs.org/package/pg-require-sql) Usage ----- Given a project like ``` |- index.js |- sql-directory |- get-record.sql ``` the following will query ```javascript var Promise = require('bluebird') var path = require('path') var getConnection = require('pg-connect')(connectionString) var requireSql = require('pg-require-sql') var sql = requireSql(path.join(__dirname, 'sql-directory')) Promise.using( getConnection(), sql.getRecord(['foo']) ). then(function (results) { // ... use the results }) ```