-
-
Save bahkostya/3fcf01df409a5cd26b95f3b579c642c6 to your computer and use it in GitHub Desktop.
Reset WebSQL database dropping every tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = openDatabase('myDatabase', '', 'My database description', 5 * 1024 * 1024); | |
if (reinitDb) { | |
db.changeVersion(db.version, '', function(t) { | |
t.executeSql("SELECT name FROM sqlite_master WHERE type='table' and name not like '__Webkit%'", [], function(sqlTransaction, sqlResultSet) { | |
var table, tablesNumber = sqlResultSet.rows.length; | |
console.log('DATABASE RESET MODE ENABLED'); | |
for (var i = 0; i < tablesNumber; i++) { | |
table = sqlResultSet.rows.item(i); | |
console.log('Removing table: ' + table.name); | |
sqlTransaction.executeSql('DROP TABLE ' + table.name); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment