This package has been deprecated

Author message:

`pg-sql-tag` is no longer maintained. Use `sql-tag@^1.0.0` instead (https://npmjs.com/sql-tag) for compatibility with `pg`.

pg-sql-tag

0.0.2 • Public • Published

pg-sql-tag

A pg plugin for sql-tag, combinining the elegance of tagged sql query strings with the convenience and safety of pg.query.

Status

This module has been deprecated in favour of sql-tag@^1.0.0, which is now able to handle pg queries without requiring any modification to pg.query.

maintenance status npm version build status

Installation

Install the package via npm:

$ npm install pg-sql-tag

Usage

var pg = require('pg');
var sql = require('sql-tag');
 
// Wrap `pg` in order to support queries
// generated by the `sql` tag.
require('pg-sql-tag')(pg);
 
// Use expressions inside placeholders to build elegant
// and readable queries.
pg.query(sql`SELECT * FROM "Foo" WHERE id = ${ 1 * 2 }`, function(err, result) {
  if (err) {
    throw err;
  }
 
  console.log(result);
});
 
// You can even use function calls inside expressions.
var obj = { foo: 'bar' }
 
pg.query(sql`UPDATE "Foo" SET biz = ${ JSON.stringify(obj) }`, function(err, result) {
  if (err) {
    throw err;
  }
 
  console.log(result);
});

Tests

$ npm test

License

MIT

Package Sidebar

Install

npm i pg-sql-tag

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • ruimarinho