Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

sql-template-strings

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "sql-template-strings",
"version": "1.0.1",
"version": "1.0.2",
"description": "Allows you to use ES6 tagged template strings for prepared statements with mysql and postgres",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,2 +9,3 @@ A simple yet powerful module to allow you to use ES6 tagged template strings for prepared/escaped statements in [mysql](https://www.npmjs.com/package/mysql) / [mysql2](https://www.npmjs.com/package/mysql2) and [postgres](https://www.npmjs.com/package/pq) (and with simple, I mean only 7 lines of code!).

// mysql (for mysql2 prepared statements, just replace query with execute):
mysql.query('SELECT author FROM books WHERE name = ?', [book]);

@@ -14,2 +15,3 @@ // is equivalent to

// postgres:
pg.query('SELECT author FROM books WHERE name = $1', [book]);

@@ -19,3 +21,2 @@ // is equivalent to

```
For mysql2 prepared statements, just replace `query` with `execute`.
This might not seem like a big deal, but when you do an INSERT with a lot columns writing all the placeholders becomes a nightmare:

@@ -28,3 +29,3 @@

);
// is equivalent to
// is better written as
db.query(SQL`

@@ -31,0 +32,0 @@ INSERT

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc