0
I have an object that is formed by various functions. these functions are table names that from a previous treatment I have to run them. The idea of the code is, if a table does not exist, perform such a function that will create it based on your code.
below follows 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 that? I’m not being able to think of a way for me to name my functions logically and call them. and I don’t want to make a series of cases, because in this case to each new table I would have to modify this function (unnecessarily reprogramming in my view)...
Some help?
Excellent explanation, thank you very much, certainly helped me pacas!!!
– LeandroLuk
Able, Leandro :) I hope it worked out there, hugging!
– Rui Pimentel