psql-query-template
It empowers one to write complex and safe Postgres queries.
Problems it solves
- static sql queries do not scale
- its hard to express complex db queries using ORM and query builders
Installation
yarn add psql-query-template
or
npm install --save psql-query-template
Walkthrough
const sql where and or limit = // prepare a db clientconst Client = const client = await client const queryParams = search: "lal" location: "sydney" page: 2 limit: 50 // psql-query-template makes use of tagged template// visit https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates// prepare query templateconst query = sql`SELECT * FROM user ;` console>>>> SELECT * FROM user>>>> >>>> LIMIT $3>>>> OFFSET $4>> ; console>> "lal" "sydney" 50 50 // query the dbconst res = await client