sql-params
Use anonymous objects instead of arrays when using parametric SQL queries.
Installation
$ npm install sql-params
Usage
var sqlParams = ; var sql = 'select * from user where points > @points and id = @id';var params = points: 24 id: 123 ; var opts = ;
Returns a hash with the pg
-ready parametric SQL string and array of values:
text : 'select * from user where points > $1 and id = $2' values : 24 123
You can even pass it directly when using the query
method with the pg
driver:
pg;
Testing
$ npm test
License
MIT