JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q32726F
  • License MIT

ES6 tagged template string functions for SQL statements.

Package Exports

  • sql-tags

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sql-tags) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SQL Templates Tag

ES6 tag functions for SQL template strings.

WARNING: This project is still under development and the API is subject to change.

DEMO

const sql = require('sql-tags');

const userTable = 'users';
const userTableColumns = ['id', 'email', 'password', 'created', 'modified'];

const usersSelectQuery = sql`
  SELECT ${{ columns: ['id', 'email', 'password', 'created', 'modified']}}
  FROM ${{ table: 'users' }}
  WHERE email = ${{ value: 'email' }} AND password = ${{ value: 'password' }}
`;

console.log(userSelectQuery('foo@bar.com', 'secret'));
// => {
// =>   text: 'SELECT "id", "email", "password", "created", "modified" FROM users WHERE email = $1 AND password = $2',
// =>   values: ['foo@bar.com', 'secret']
// = }

License

MIT