0.1.7 • Published 4 years ago

pg-query-string v0.1.7

Weekly downloads
33
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

pg-query-string Build Status

npm install pg-query-string

Thanks to https://github.com/hiddentao/squel

This is essentially squel, however a few changes:

  • built with babel instead of gulp
  • hard-coded to postgres
  • added type coersions
  • classes handy for testing
import { Table, Schema } from 'pg-query-string';

const schema = new Schema('my-schema');
const table = schema.table('users', {
  id: 'uuid',
  username: 'text',
  email: 'email',
  password: 'password',
  active: 'boolean',
  tags: 'text[]'
});

table.update(
  {
    active: true,
    tags: ['pyramation']
  },
  {
    id: 1
  }
);

Which produces the following object

Object {
  "text": "UPDATE \\"my-schema\\".users SET active = $1::boolean, tags = ($2::text[]) WHERE (id = $3::uuid)",
  "values": Array [
    true,
    Array [
      "pyramation",
    ],
    1,
  ],
}
0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago