You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm making a refactoring to node.js project from callbacks to async await es7 feature, so in that refactoring stage I was migrating from mysql to mysql2 driver. I'm using mysq2/promise so everything works well with new async await keyword, but I have one small problem. When I'm returning promise<RowDataPacket[]> from select, update or insert i can't use for or loop.
Now, when I use this selectAsync for example in some function and when the data are fetched from db I can't loop with for of loop when I execute multiples sql queries at once:
for(letrowofresult[0]){// some code}
result[0] or result[1] gives error that the RowDataPacket must have a symbol iterator. One workaround is to use forEach, but I don't like to change forEeach everywhere where I have for of loop already from previously when for of loop was working with mysql driver.
BR, Igor
The text was updated successfully, but these errors were encountered:
Hi,
I'm making a refactoring to node.js project from callbacks to async await es7 feature, so in that refactoring stage I was migrating from mysql to mysql2 driver. I'm using mysq2/promise so everything works well with new async await keyword, but I have one small problem. When I'm returning promise<RowDataPacket[]> from select, update or insert i can't use for or loop.
Now, when I use this selectAsync for example in some function and when the data are fetched from db I can't loop with for of loop when I execute multiples sql queries at once:
result[0] or result[1] gives error that the RowDataPacket must have a symbol iterator. One workaround is to use forEach, but I don't like to change forEeach everywhere where I have for of loop already from previously when for of loop was working with mysql driver.
BR, Igor
The text was updated successfully, but these errors were encountered: