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

111
Views
Scope of variable in WebSQL

I have this function

const _getCountriesByContinentCode = continent_code => {
    const someDb = SQLite.openDatabase(db);
    let foo = [];
    someDb.transaction(tx => {
        tx.executeSql("SOME SQL", [], (tx, results) => {
            for (let i = 0; i < results.rows.length; i++) {
                foo.push((results.rows.item(i)));
            }
            console.log('####', foo) // this logs the result as expected
        });
    });
    console.log('****', foo) // this does not log the pushed result, but an empty array 
}

The console.log('####', foo) logs as expected the results of foo.push(...). However, the console.log('****', foo) logs an empty array.

Why is that? Is someDb.transaction(... asynchronus?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Indeed, as @Bergi suggest in the comment below the Q: SQL.transaction and SQL.executeSql are both asynchronous.

about 4 years ago · Juan Pablo Isaza Report
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!