
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
sql-string-template
Advanced tools
A tiny tool allow you to use ES2015 template strings to render a sql prepared statements. (Only support quest mark placeholder for now!).
const SQL = require('sql-string-template');
const data = {
name: "jon",
age: 12
};
const stmt = SQL`
INSERT INTO account
(name, age)
values
(${data.name}, ${data.age})
`;
// stmt.sql: "INSERT INTO account (name, age) values (?, ?)"
// stmt.params: ["jon", 12]
*/
values
functionconst SQL = require('sql-string-template');
const { values } = SQL;
const data = { name: "jon", age: 12 };
const [sql, params] = SQL`
INSERT INTO account ${values(data)}
`.pack();
// sql: "INSERT INTO account (name, age) values (?, ?)"
// params: ["jon", 12]
const SQL = require('sql-string-template');
const [sql, params] = SQL`
UPDATE account SET ${SQL.set({
name: "jon",
age: 12,
school: null,
})}
`.pack();
/*
sql: "UPDATE account SET name=?, age=?, school=?"
params: ["jon", 12, null]
*/
const SQL = require('sql-string-template');
const startDate = '2020-5-5';
const endDate = undefined;
const stmt = SQL`
SELECT
${['id', 'name', 'pwd'].join(', ')}
FROM
account
WHERE
1=1
${startDate && SQL`AND startDate = ${startDate}`}
${endDate && SQL`AND endDate = ${endDate}`}
`;
/*
stmt.sql: "SELECT id, name, pwd FROM account WHERE 1=1 AND startDate=?"
stmt.params: ["2020-5-5"]
*/
FAQs
ES2015 tagged template string for preparing statements
The npm package sql-string-template receives a total of 3 weekly downloads. As such, sql-string-template popularity was classified as not popular.
We found that sql-string-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.