pg-params
v2.0.2
Published
pg doesn't support named parameters, to keep things lightweight and simple. However, that makes queries brittle.
Downloads
13
Readme
pg-params
pg doesn't support named parameters, to keep things lightweight and simple. However, that makes queries brittle.
pg-params contains helper methods to make parameterized queries easier.
Installation
npm install pg-params
Usage
Here's an example.
import Params from "pg-params";
const params = Params({
name: "jeswin",
country: "india"
});
const queryText = `
SELECT * FROM user WHERE
name=${dbParams.id("name")} AND
country=${dbParams.id("country")}`;
client.query(queryText, dbParams.values());