Skip to content

Commit e662139

Browse files
committed
update README
1 parent 0f9dae4 commit e662139

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@ let SQL = require('sql-template-strings');
66

77
let book = 'harry potter';
88

9+
// mysql (for mysql2 prepared statements, just replace query with execute):
910
mysql.query('SELECT author FROM books WHERE name = ?', [book]);
1011
// is equivalent to
1112
mysql.query(SQL`SELECT author FROM books WHERE name = ${book}`);
1213

14+
// postgres:
1315
pg.query('SELECT author FROM books WHERE name = $1', [book]);
1416
// is equivalent to
1517
pg.query(SQL`SELECT author FROM books WHERE name = ${book}`);
1618
```
17-
For mysql2 prepared statements, just replace `query` with `execute`.
1819
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:
1920

2021
```js
2122
db.query(
2223
'INSERT INTO books (name, author, isbn, category, recommended_age, pages, price) VALUES (?, ?, ?, ?, ?, ?, ?)',
2324
[name, author, isbn, category, recommendedAge, pages, price]
2425
);
25-
// is equivalent to
26+
// is better written as
2627
db.query(SQL`
2728
INSERT
2829
INTO books

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sql-template-strings",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Allows you to use ES6 tagged template strings for prepared statements with mysql and postgres",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)