You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

sql-template-strings

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-template-strings - npm Package Compare versions

Comparing version

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