Skip to content

Instantly share code, notes, and snippets.

@KirinDave
Created August 11, 2008 18:40
Show Gist options
  • Save KirinDave/4915 to your computer and use it in GitHub Desktop.
Save KirinDave/4915 to your computer and use it in GitHub Desktop.
validate_tables: function() {
// Sometimes you can have as much fun indoors as outdoors.
var self = this;
var found = 0; var needed = this.tables.length; var reported = 0;
var callback = function(present) {
if(present) {
found += 1;
}
reported += 1;
if(reported == needed) {
if(found < needed) {
self.insert_schema();
}
self.setup_helpers();
self.initalized = true
}
}
this.tables.each( function(x) {
self.db_handle.transaction( function(tx) {
tx.executeSql( "SELECT COUNT(*) FROM " + x[0], [],
function(tx, r) {callback(true)},
function(tx, error) {callback(false)})
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment