Package Exports
- sql-tag
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-tag) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sql-tag
A template tag for writing elegant sql strings based on ES6 tagged template strings.
Status
Installation
Install the package via npm:
$ npm install sql-tagUsage
Arguments
query(string): The sql query.[...*](...*): The query replacements.
Returns
(Object): A structured object with the sql query string and its replacements.
Example
var sql = require('sql-tag');
var out = sql`SELECT * FROM "Foo" WHERE id = ${1}`;
// => { query: 'SELECT * FROM "Foo WHERE id = ?', values: [1] }The tag itself is framework agnostic. It should just require a small modification to the query generator function.
NOTE: the sql tag does not provide any kind of escaping safety. It delegates that work to the underlying framework.
Integrating with sequelize
Check out the sequelize-sql-tag plugin.
Integrating with pg
Check out the pg-sql-tag plugin.
Tests
$ npm testCredits
Inspired by the awesome Taras Mitran post.
License
MIT