1.9.0 • Published 4 years ago

@ravshansbox/sql-helpers v1.9.0

Weekly downloads
15
License
MIT
Repository
github
Last release
4 years ago

SQL helpers

Usage examples

const { Client } = require('pg');
const sh = require('@ravshansbox/sql-helpers');

const client = new Client();

const queryConfig = sh.sqlQuery(
  'select',
  sh.sqlSeparator([
    't1.column1_1', 't1.column1_2', 't2.column2_1',
    ['json_build_object', sh.sqlWrap(sh.sqlEntries({id: 't1.id', desc: 't2.desc'}))]
  ]),
  'from table1 as t1',
  'join table2 as t2', sh.sqlOnMap({
    't2.ref_id': 't1.id'
  }),
  sh.sqlWhere(
    sh.sqlOperator('and',
      ['t1.column1_1', '>', 't1.column1_2'],
      sh.sqlEqual('t2.column2_1', sh.sqlValue('abc'))
    )
  ),
  sh.sqlGroupBy('t1.column1_1', 't1.column1_2', 't2.column2_1')
);

client.query(queryConfig).then(console.info, console.error);
1.9.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago