JSPM

  • Created
  • Published
  • Downloads 29910
  • Score
    100M100P100Q151842F
  • License ISC

Parse user input into PostgreSQL tsquery

Package Exports

  • pg-tsquery

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pg-tsquery) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pg text-search sanitizer Build Status

Like plainto_tsquery operator but allows any inputs without letting pg throws

const tsquery = require('pg-tsquery');

pool.query("SELECT * FROM tabby WHERE to_tsvector(col) @@ to_tsquery($1)", [tsquery(str)])

Examples of inputs

  • foo bar
  • foo -bar is like foo !bar, foo + !bar and foo&!bar the final form
  • foo bar,bip is like foo+bar | bip and foo&bar|bip the final form

Notes:

  • ()<: are ignored
  • it's safe to add :* at the end of the result of tsquery, if it's not empty, for substring matching