https://github.com/christianmalek/node-mysql-es6-query
A helper function to build queries with ES6 template strings.
https://github.com/christianmalek/node-mysql-es6-query
es6 mysql node-mysql nodejs
Last synced: about 2 months ago
JSON representation
A helper function to build queries with ES6 template strings.
- Host: GitHub
- URL: https://github.com/christianmalek/node-mysql-es6-query
- Owner: christianmalek
- Created: 2016-01-09T23:37:36.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-09T23:44:44.000Z (over 10 years ago)
- Last Synced: 2025-07-02T19:51:32.458Z (11 months ago)
- Topics: es6, mysql, node-mysql, nodejs
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-mysql-es6-query
A helper function to build queries with ES6 template strings in [node-mysql](https://github.com/felixge/node-mysql).
## How it works
```js
"use strict";
//require the node mysql module
let mysql = require("mysql");
//require the es6 query file and pass the mysql.escape fn
let SQL = require( "sql"))(mysql.escape);
//now you can write SQL in front of the ES6 Template Strings and they get escaped
connection.query(SQL`SELECT username, password
FROM account
WHERE username = ${username}
LIMIT 1`, (err, rows) => {
//more code
});