Skip to content

Commit 48cff07

Browse files
anlitingdougwilson
authored andcommitted
docs: document single value as .query second argument
closes #1979
1 parent 6454f19 commit 48cff07

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,22 @@ connection.query({
661661
);
662662
```
663663

664+
If the query only has a single replacement character (`?`), and the value is
665+
not `null`, `undefiend`, or an array, it can be passed directly as the second
666+
argument to `.query`:
667+
668+
```js
669+
connection.query(
670+
'SELECT * FROM `books` WHERE `author` = ?',
671+
'David',
672+
function (error, results, fields) {
673+
// error will be an Error if one occurred during the query
674+
// results will contain the results of the query
675+
// fields will contain information about the returned results fields (if any)
676+
}
677+
);
678+
```
679+
664680
## Escaping query values
665681

666682
**Caution** These methods of escaping values only works when the

0 commit comments

Comments
 (0)