You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-4Lines changed: 18 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
A simple yet powerful module to allow you to use ES6 tagged template strings for prepared/escaped statements in mysql/mysql2 and postgres (and with simple, I mean only 7 lines of code!).
1
+
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!).
2
2
3
-
Examples (callbacks omitted):
3
+
Example for escaping queries (callbacks omitted):
4
4
```js
5
5
letSQL=require('sql-template-strings');
6
6
@@ -14,7 +14,7 @@ pg.query('SELECT author FROM books WHERE name = $1', [book]);
14
14
// is equivalent to
15
15
pg.query(SQL`SELECT author FROM books WHERE name =${book}`);
16
16
```
17
-
17
+
For mysql2 prepared statements, just replace `query` with `execute`.
18
18
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:
0 commit comments