Use this with async / await?
blaasvaer opened this issue · 1 comments
blaasvaer commented
I've been using the npm package 'pg' and need to switch to this npm package 'mysql'. And I've been using the 'pg' package like this:
const res = await pool.query( query );
But since the 'mysql' package uses a callback, I need to do this:
const res = await pool.query( query, function ( error, results, fields ) { return results; // ABBREVIATED } );
The callback gets fired immediately and does not return to the calling function ... now, how do I make this package work with the above method? I don't know whether this is an actual 'issue' or the package is simply just not Promisified.
blaasvaer commented
Well, the simple solution is to wrap the whole thing in a new Promise and return it.