Skip to content

Commit 222c873

Browse files
committed
docs: add raw method mention to formatting section
1 parent 9c88ed5 commit 222c873

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ You also have the option (but are not required) to pass in `stringifyObject` and
181181
allowing you provide a custom means of turning objects into strings, as well as a
182182
location-specific/timezone-aware `Date`.
183183

184+
This can be further combined with the `SqlString.raw()` helper to generate SQL
185+
that includes MySQL functions as dynamic vales:
186+
187+
```js
188+
var userId = 1;
189+
var data = { email: '[email protected]', modified: SqlString.raw('NOW()') };
190+
var sql = SqlString.format('UPDATE ?? SET ? WHERE `id` = ?', ['users', data, userId]);
191+
console.log(sql); // UPDATE `users` SET `email` = '[email protected]', `modified` = NOW() WHERE `id` = 1
192+
```
193+
184194
## License
185195

186196
[MIT](LICENSE)

0 commit comments

Comments
 (0)