mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
doc: show the use of string expressions in the SQLTagStore example
If a users attempts to escape strings with quotes in SQLTagStore
template strings (`'${expression}'`), as is usually required for
SQL query strings, the queries would fail. This change shows an
example on the correct use (`${expression}`).
PR-URL: https://github.com/nodejs/node/pull/60873
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
@@ -550,8 +550,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`;
|
||||
sql.run`INSERT INTO users VALUES (2, 'Bob')`;
|
||||
|
||||
// Using the 'get' method to retrieve a single row.
|
||||
const id = 1;
|
||||
const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
|
||||
const name = 'Alice';
|
||||
const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
|
||||
console.log(user); // { id: 1, name: 'Alice' }
|
||||
|
||||
// Using the 'all' method to retrieve all rows.
|
||||
@@ -577,8 +577,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`;
|
||||
sql.run`INSERT INTO users VALUES (2, 'Bob')`;
|
||||
|
||||
// Using the 'get' method to retrieve a single row.
|
||||
const id = 1;
|
||||
const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
|
||||
const name = 'Alice';
|
||||
const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
|
||||
console.log(user); // { id: 1, name: 'Alice' }
|
||||
|
||||
// Using the 'all' method to retrieve all rows.
|
||||
|
||||
Reference in New Issue
Block a user