@gasbuddy/configured-postgres-client

A configuration driven postgres client

Stats

StarsIssuesVersionUpdatedCreatedSize
@gasbuddy/configured-postgres-client
8.0.02 years ago5 years agoMinified + gzip package size for @gasbuddy/configured-postgres-client in KB

Readme

configured-postgres-client

Greenkeeper badge wercker status

A small wrapper around pg/pg-promise to allow configuration from confit and tracking of start/finish/error on all queries.

Supports the following methods from pg-promise: connect, any, none, one, oneOrNone, many, manyOrNone, result, tx, task

SQL Files

This module also supports Query files from PGPromise. In your config, pass in the directory of your query files. You will then get an object that has the same structure as the folders you defined.

If your folder structure looks like this:

 - feature
    - create.sql
    - getById.sql

You could make a DB call like this:

async getById(featureId, locale) {
    let returnFeature = null;
    const sqlFiles = this.dbClient.sqlFiles;
    const dbFeature = await this.dbClient.oneOrNone(sqlFiles.feature.getById, [featureId, locale]);
    if (dbFeature) {
      returnFeature = dbFeature.metadata;
    }
   return returnFeature;
 }

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.