Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Await inside nodejs snowflake stream.on('data', fn)

I want to process the data stream and insert it in DB synchronously. How can do it. If I pass an async function to stream.on it won't be processed synchronously.

return new Promise(async (resolve, reject) => {
    logger.info("Initiating snowflake connection")
    const connection = await getConnection();
    const statement = await connection.execute({
        sqlText: 'SELECT * FROM CMO_DATA;',
        complete: function (err, stmt, rows) {
            var stream = statement.streamRows();
            stream.on('data', async function (row) {
                logger.info("Processing data =>", row)
                await SnowflakeData.insertOne(row);
                count++;
            });
            stream.on('end', function () {
                logger.info('All rows consumed =>', count);
                resolve()
            });
            stream.on('error', function (err) {
                logger.error('Failed to consume all rows', err);
                reject(err)
            });
        }
    });
})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!