There was an error while loading. Please reload this page.
Generates SQL command for SELECT with tsquery.
sql.selectTsquery(table, query, [tsvector], [options]); // table: table name // query: plain query words // tsvector: tsvector ("tsvector") // options: options {columns, order, limit, normalization} // .columns: select columns (*) // .order: order rows? (false) // .limit: limit rows (0 => no) // .normalization: rank normalization (0 => ignores the document length)
const sql = require('extra-sql'); sql.selectTsquery('columns', 'total fat'); // SELECT * FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat'); sql.selectTsquery('columns', 'total fat', '"tsvector"', {columns: '"code"'}); // SELECT "code" FROM "columns" WHERE "tsvector" @@ plainto_tsquery('total fat'); sql.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;