I am trying to save the results of a REST call to an sqlite db.
I have edited the code of the example, and my result is that just the first element of the REST response is being saved. At the same tome I am building a table and that is going perfectly.
Like in the example, I send the LIST [$] to a javascript variable and then execute:
-----var db = window.openDatabase("health_priorities", "", "Health List", 1024*1000);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS "priority_list_3"(id TEXT, short TEXT, desc TEXT, url TEXT, full text)', []);
Code: Select all
console.log('did i make it?');
tx.executeSql('SELECT * FROM "priority_list_3" WHERE "id" = "' + value.id + '"', [], function(tx, results){
console.log('rows :' + results.rows.length);
if (results.rows.length === 0){
console.log('Go and add table ' + value.number);
tx.executeSql('INSERT INTO "priority_list_3" (id, short, desc, url) values (?, ?, ?, ?)', [value.id, value.short, value.desc, value.url]);
}
});
});
return;
-----It is only saving the first element of the result, however, at the same time it is building a table correctly with the data.
What did I miss to make it iterated through the results and add all results?