Remove row from result set in web sql using javascript

I understand that the result set from web sql is not quite an array, is it more an object? I ride my bike in the result set and speed up the work. I would like to delete the line after it is detected. I tried "delete" and "merge", the former does nothing, and the latter throws an error. Here is part of what I'm trying to do, notice the deletion on line 18:

function selectFromReverse(reverseRay,suggRay){ var reverseString = reverseRay.toString(); db.transaction(function (tx) { tx.executeSql('SELECT votecount, comboid FROM counterCombos WHERE comboid IN ('+reverseString+') AND votecount>0', [], function(tx, results){ processSelectFromReverse(results,suggRay); }); }, function(){onError}); } function processSelectFromReverse(results,suggRay){ var i = suggRay.length; while(i--){ var j = results.rows.length; while(j--){ console.log('searching'); var found = 0; if(suggRay[i].reverse == results.rows.item(j).comboid){ delete results.rows.item(j); console.log('found'); found++; break; } } if(found == 0){ console.log('lost'); } } } 
+4
source share
3 answers

In fact, you use the DELETE sql command to delete a record from the database. For instance:

 tx.executeSql('DELETE FROM counterCombos WHERE comboid = ?', [comboid], success, error); 

processSelectFromReverse can be modified to include tx as input, e.g.

 processSelectFromReverse(results,suggRay,tx) 
+7
source

Web SQL has been removed from HTML5 for almost 2 years and is not supported. Web Storage and Indexed DB took their place.

Your syntax for deleting objects: delete object; correct. It is often not used in JavaScript, but I used it, and that is the correct use.

Using web storage (usually called local storage), you will create a localStorage object that comes with the removeItem(item key) method already installed.

You can see more at the link above in webstorage or go here for the tutorial .

0
source

If your problem is with iOS or Android, creating an application that is wrapped initially will allow you to create a javascript interface. From this interface you can access (for android) sqlite and create a nice query0able solution. The disadvantage of this is that users will need to download the application, not access to the site.

http://caniuse.com/indexeddb

Support

indexeddb is growing quite slowly. With the right coding style, you can probably use local storage (as indicated in the comments above) with pretty respectable speeds.

0
source

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


All Articles