0.1.1 • Published 7 years ago

@sql-extra/selecttsquery v0.1.1

Weekly downloads
2
License
MIT
Repository
-
Last release
7 years ago

@sql-extra/selecttsquery

sql-extra

Generate SQL command for SELECT with tsquery.

const selectTsquery = require('@sql-extra/selecttsquery');
// selectTsquery(<table>, <query>, [tsvector], [options])
// -> sql command

// options: {
//   columns: '*',  // select columns: all
//   order: false,  // order rows: no
//   limit: null,   // limit rows: no
//   normalization: 0,  // rank normalization: ignores the document length
// }


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

selectTsquery('columns', 'total fat', '"tsvector"', {columns: '"code"'});
// SELECT "code" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat');

selectTsquery('columns', 'total fat', '"tsvector"', {order: true, limit: 1, normalization: 2});
// SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat') ORDER BY ts_rank("tsvector", plainto_tsquery('total fat'), 2) DESC LIMIT 1;
0.1.1

7 years ago

0.1.0

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago