Registry / database / sequelize-sql-tag

sequelize-sql-tag

JSON →
library2.0.2jsnpmunverified

A template tag for writing parameterized SQL queries using ES2015 tagged template literals with Sequelize. Current stable version is 2.0.2, which works with Sequelize >=3.14.0 and >=4.0.0-0. This package simplifies building safe SQL queries by leveraging tagged template literals, automatically converting them into parameterized queries to prevent SQL injection. Compared to raw string concatenation or manual escaping, it provides a cleaner syntax and seamless integration with Sequelize's query interface. The release cadence is low; no updates since 2018.

npm install sequelize-sql-tag
INSTALL
IMPORT
SIG · SEQUELIZE-SQL-TAG
S
sequelize-sql-tag
databasejavascriptv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import sql from 'sequelize-sql-tag';
✗ const { sql } = require('sequelize-sql-tag');
The package exports a single function as default export. In CommonJS, use require('sequelize-sql-tag') directly.
sql
✓ const sql = require('sequelize-sql-tag');
✗ const { sql } = require('sequelize-sql-tag');
CommonJS require returns the default export directly, not an object with property.
Sequelize
✓ const Sequelize = require('sequelize');
Not part of this package, but needed to use the sql tag with Sequelize query.

Shows basic usage: create Sequelize instance, use sql tag with parameterized query and execute via sequelize.query().

const Sequelize = require('sequelize'); const sql = require('sequelize-sql-tag'); const sequelize = new Sequelize('sqlite', 'sqlite', 'sqlite', { dialect: 'sqlite', logging: false }); async function run() { const [results, meta] = await sequelize.query(sql`SELECT ${1 + 1} AS foo`); console.log(results); // [ { foo: 2 } ] } run();
Debug
Known issues
breakingVersion 2.0.0 changed the output format and requires Sequelize >= 3.14.0 that supports parameterized queries. Do not use with older Sequelize versions without upgrading.
fix
Upgrade Sequelize to >=3.14.0 or >=4.0.0-0. If on older Sequelize, use sequelize-sql-tag@1.x and patch.
affects: >=2.0.0
gotchaThe sql tag returns an object with `query` and `values` properties. Sequelize's query method expects separate arguments when using parameterized queries. Ensure you pass the result directly to `sequelize.query()` without destructuring.
fix
Use `sequelize.query(sql`...`)` not `sequelize.query(sql(...).query, { replacements: sql(...).values })`.
affects: >=2.0.0
deprecatedThis package is not actively maintained; last release in 2018. May not work with Sequelize v5+ without issues.
fix
Consider using Sequelize's built-in `replacements` or `bind` parameters directly.
affects: >=2.0.2
gotchaNode.js versions >=4 are supported, but modern Sequelize may require Node >=6 or later. Check compatibility.
fix
Use Node >=6 for best compatibility with Sequelize.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'sequelize-sql-tag'
Package not installed or import path incorrect.
fix
Run `npm install sequelize-sql-tag` and ensure correct require/import.
sql is not a function
Incorrect import: using destructured import instead of default.
fix
Use `const sql = require('sequelize-sql-tag');`
Sequelize version 3.14.0 is required for parameterized queries. Upgrade Sequelize or use an older version of this package.
Using sequelize-sql-tag v2 with Sequelize < 3.14.0.
fix
Upgrade Sequelize to >=3.14.0 or use sequelize-sql-tag v1.x.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
sequelizerequiredPeer dependency; required for query execution and parameterized query support
Agent activity
11 hits · last 30 days
node
10
Resources
sequelize-sql-tag — npm install sequelize-sql-tag · libregistry