I have an object that is made up of several functions. these functions are names of tables that, from an earlier treatment I have to execute them. The idea of the code is, if a table does not exist, execute such a function that will create it based on your code.
Below is the function:
//WebSQL connect db
d = openDatabase('test', 'test', 'app', 200 * 1024 * 1024);
db = {
stage : function(){
//app tables
var sys_tables = ['license','config'];
//verify integrity from database
d.transaction(function (tx) {
//sql
tx.executeSql('SELECT name FROM sqlite_master',[],function(tx, result){
//catch num rows in select
var len = result.rows.length, i;
//for for in sql, search if this val exist in sys_tables
for (i = 0; i < len; i++){
//if not exist, call function to create this table
if($.inArray(result.rows.item(i).name , sys_tables) < 0){
var table = 'db.make'+result.rows.item(i).name+'()';
//>>>>>>>>>>>>HELP HERE<<<<<<<<<<<<
console.log(table);
//>>>>>>>>>>>>HELP HERE<<<<<<<<<<<<
}
};
},null);
});
},
make : {
//create a license table...
license : function(){
//code...
},
//create a config table...
config : function(){
//code...
}
}
}
Does anyone have a solution for this? I can not think of a way for me to logically name my functions and call them. and I do not want to do a series of cases, because in this case with each new table I would have to modify this function (unnecessary reprogramming in my view) ...
Any help?