I wrote the following function
to check if my HTML5 openDatabase
table is filled or empty:
var that = this;
that.db = openDatabase('dbname', '1.0', "description", 1024 * 1024);
that.tableFilled = function( tableName ) {
that.db.transaction(function ( tx ) {
tx.executeSql('SELECT * FROM ' + tableName, [],
function success( c, results ) {
return ( results.rows.length > 0 ? true : false );
},
function fail() {
console.log('FAiL');
}
);
});
};
I am trying to return
the true
or false
values to tableFilled()
.
Actually that.tableFilled('tableName')
returns undefined
.
What I am trying to achieve at the end is:
if ( that.tableFilled('tableName') ){
// ...
}
Is there a way I can return
the true
or false
values to the parent function tableFilled()
without using a callback ?