Suppose I use node-mysql from npm to execute sql queries. With the advent of node 7 and the support of async / await, I would like to understand how you can apply this to perform sql queries? The task as a whole is to write a wrapper class for node-mysql so that later you can do something like:
let data = new MySqlWrapper().select(query); Well, in the end, in data we have the result of the query.
Tell me how you can implement this in this example:
(async () => { let getData = async ()=> { db.query(`select * from users`,null,(err,data) =>{ console.log('ok'); return data; }); }; var res = await getData(); //нужно чтобы в res пришли данные запроса })();