pga-sql
A template tagging function that returns an object compatible with the pg module's querying methods.
Installation
npm install --save pga-sql
Usage
pga-sql
provides a template tagging function that returns an object compatible with node-postgres
's querying methods and, by extension, pga
's query
, parallel
, and transact
methods. Template literal variable interpolation makes writing lengthy parameterized queries much cleaner.
Regular variables may be interpolated as string literals (without applying parameterized filtering from the node-postgres
module) by prefixing them with an additional $
character. This is unsafe, and should be used carefully.
Query
const pga = ;const sql = ; var db = ; var id = 1;var table = 'test';var query = sql`SELECT * FROM $ WHERE id = ;`; db;