0.0.13 • Published 6 years ago

pg-simple-wrapper v0.0.13

Weekly downloads
14
License
MIT
Repository
github
Last release
6 years ago

pg-simple-wrapper NPM version Build Status Dependency Status

Simple wrapper around postgresql transactions using pg.

Install

Include with "npm install" or "yarn add":

yarn add pg-simple-wrapper --dev

Usage

Really simple query-forming wrapper around pg that cleans up (a bit) sql statement generation for common operations (select list, insert single, access single, etc.).

Used as a typescript module.

import { Xaxion } from 'pg-simple-wrapper';

class ModelRepository {

  client: Xaxion;

  async accessPooled(pooledCode: string): Promise<Pooled> {
    return this.client.access<Pooled>(ModelPooled, 'pooledId', {
      props: '* from "pooled" as p',
      where: 'p."ucode" = $#',
      param: [
        pooledCode,
      ]
    });
  }

  // ...

}

That's a trivial example, but should give you an idea of how it works. Keep in mind that in the above example, ModelPooled must have the following "construction":

 export interface Pooled {

  ucode: string;

  // ...

}
import { Xaxion } from 'pg-simple-wrapper';
import { Pooled } from './Pooled';

export class ModelPooled implements Pooled {

  constructor(private client: Xaxion, private id: number, that: {
    ucode: string,
  }) {
    this.ucode = that.ucode;
  }

  ucode: string = '';

  // ...
  
}

License

MIT © Kirk Bulis

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago