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 having trouble finding clear examples of how to perform a query and process the result stream synchronously. I've tried the following example from this comment but thePromise hangs, so the script never executes the next line, and node just sits there without exiting (never reaches the connection close line either):
constthingsWeCareAbout=newMap();awaitnewPromise((resolve,reject)=>{consts1=connection.query('SELECT a lot of stuff').stream();s1.on('result',row=>{// logic to determine if we care about this rowthingsWeCareAbout.set('foreignKeyFromQuery',['stuff','to','process','later']);});s1.on('end',resolve);s1.on('error',reject);});doMoreStuff(thingsWeCareAbout);// this never executes; script is hung
I need to pull millions of rows, but don't want to load the whole thing into memory. I also can't move on to the next step until all the rows have been examined by a function that determines if we need to do something in the next step (it's a chain of ETL functions for a data warehouse).
The text was updated successfully, but these errors were encountered:
I'm having trouble finding clear examples of how to perform a query and process the result stream synchronously. I've tried the following example from this comment but the
Promise
hangs, so the script never executes the next line, and node just sits there without exiting (never reaches the connection close line either):I need to pull millions of rows, but don't want to load the whole thing into memory. I also can't move on to the next step until all the rows have been examined by a function that determines if we need to do something in the next step (it's a chain of ETL functions for a data warehouse).
The text was updated successfully, but these errors were encountered: