In HTML5, how can I directly return the results of an SQLite call, rather than passing them to a function?

Using SQLite in HTML5, how do I make a call like the following so that it returns immediately, instead of passing the result to another function?

try {
    mydb.transaction( function(transaction) {
        transaction.executeSql(
            'SELECT name FROM celebs order by name limit 100 ',
            [],
            function(transaction, results) {
                // would like to return the "results" back
            },
            errorHandler
        );
    });
    // code to use the "results" array
} catch(e) {
    alert(e.message);
}
+3
source share
1 answer

You can not. Because JavaScript is asynchronous, it does not give you any way to lock until the lock operation is complete.

0
source

Source: https://habr.com/ru/post/1772397/


All Articles