How to execute sql query using async/await in node 7?

Let's say I'm using node-mysql from npm to execute sql queries. With the advent of node 7 and it support async/await, I would like to understand how you can apply this to execute sql queries? The problem in General is to write a class-wrapper for node-mysql, so you can do something like:
let data = new MySqlWrapper().select(query);
well, in the end we have the data in the query result.

Tell me how you can implement this on this example (it does not work in the res we undefined):
(async () => {
 let getData = async ()=> {
 db.query(`select * from users`,null,(err,data) =>{
 return data;

 var res = await getData();
 //need to res came the request data
July 2nd 19 at 18:20
2 answers
July 2nd 19 at 18:22
well, show what I did, maybe then you will understand what was the fail
updated question - tracey commented on July 2nd 19 at 18:25
July 2nd 19 at 18:24
If the select returns a promise, that in so here:
async function run() {
 let data = await (new MySqlWrapper()).select(query);


In this node you need to run with --harmony flag
I should add that async/await now with bugs (leaking memory). Podrobnee can be found here:

So be careful in production. Correct or in Node 7.x or in Node 8 - tracey commented on July 2nd 19 at 18:27
Can you give a hint in my example? (updated question) - cassidy.Green commented on July 2nd 19 at 18:30
(async () => {
 var res = await select(`select * from users`);
 //need to res came the request data

function select(query) {
 return new Promise( (r, j) => db.query(query,null,(err,data) =>{
 if (err) return j(err);
 }) )
- tracey commented on July 2nd 19 at 18:33
: thank you) - braulio_Welch commented on July 2nd 19 at 18:36

Find more questions by tags Node.jsJavaScript