pg-builder

PostgreSQL query builder

pg-builder

PostgreSQL query builder

npm install pg-builder

var q = require('pg-builder')()
.select('user_id', 'username')
.select('age')
.from('users')
.where('age >= ${minAge}')
.order('username', 'asc')
.limit(500)
.param('minAge', 27)
 
console.log(q.text)
console.log(q.values)
 
/*
SELECT user_id, username, age
FROM users
WHERE age >= $1
ORDER BY username
LIMIT 500
[ 27 ]
*/

See tests for more