sql-tools

0.1.2 • Public • Published

sql-tools

olap for sql non-olap engines / and other tools

designing version downloads build coverage climate dependencies

language: English also available in: Spanish

Install

$ npm install sql-tools

Main goal

Transfor a SQL sentence in a SQL with totals.

Definitions

Uses a list of field definition with the form:

attribute mandatory use
name yes name of the field in the database
place yes 'data' if must be added, 'left' or 'top' if it must apear in the GROUP BY clausule
aggLabel for pivot text to insert in the added rows
aggExp no the expression when is different to SUM(x)

Example

var olap = require('sql-tools').olap;

var varsDef=[
  {name: "zone", place:"left", aggLabel:"=SUM="}, 
  {name: "kind", place:"left"},
  {name: "sales", place:"data"},
  {name: "calif", place:"data", aggExp:"min(calif)"}
];

var sql_total=olap.cube("select * from sales", 'zone', varsDef);

console.log(sql_total);
/*
WITH "olap cube" AS (
 select * from sales
) SELECT * FROM "olap cube"
UNION SELECT '=SUM=', kind, SUM(sales), min(calif)
  FROM "olap cube"
  GROUP BY kind
*/

License

MIT

.............................

Readme

Keywords

none

Package Sidebar

Install

npm i sql-tools

Weekly Downloads

21

Version

0.1.2

License

MIT

Unpacked Size

16.5 kB

Total Files

5

Last publish

Collaborators

  • tute
  • manueldelapenna
  • u-gene