Nincompoops Producing Methane

    @gasbuddy/configured-postgres-client

    8.0.0 • Public • Published

    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;
     }

    Install

    npm i @gasbuddy/configured-postgres-client

    DownloadsWeekly Downloads

    27

    Version

    8.0.0

    License

    UNLICENSED

    Unpacked Size

    36.3 kB

    Total Files

    17

    Last publish

    Collaborators

    • djmax