1.0.7 • Published 4 years ago

extra-sql v1.0.7

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

SQL is designed for managing or stream processing data in an RDBMS. Includes SQL command generation functions, with a few for text matching (PostgreSQL).

const sql = require('extra-sql');

sql.tableExists('food');
// SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='food');

sql.setupTable('food', {code: 'TEXT', name: 'TEXT'},
  [{code: 'F1', name: 'Mango'}, {code: 'F2', name: 'Lychee'}]);
// CREATE TABLE IF NOT EXISTS "food" ("code" TEXT, "name" TEXT);
// INSERT INTO "food" ("code", "name") VALUES
// ('F1', 'Mango'),
// ('F2', 'Lychee');

sql.selectTsquery('columns', 'total fat');
// SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat');

sql.matchTsquery('columns', ['total', 'fat']);
// SELECT *, '2'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat') UNION ALL
// SELECT *, '1'::INT AS "matchTsquery" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total'); 

reference

NameAction
createTableGenerates SQL command for CREATE TABLE.
createIndexGenerates SQL command for CREATE INDEX.
createViewGenerates SQL command for CREATE VIEW.
insertIntoGenerates SQL command for INSERT INTO.
setupTableGenerates SQL commands to setup table (create, insert, index).
tableExistsGenerates SQL command for table exists check.
selectTsqueryGenerates SQL command for SELECT with tsquery.
matchTsqueryGenerates SQL query for matching words with tsquery.
OPERATORSSet of operators in SQL. {field}
OPERAND_COUNTNumber of operands used with an SQL operator. {field}

nodef

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago