I am working on a database manager for an app. At a certain point I want to save some data like this:
//call the saveBillEvent
DatabaseManager.saveBillEvent(model, callbackfunc);
//accepts billeventmodel object
DatabaseManager.prototype.saveBillEvent = function(billEventModel, callback){
db.transaction(
RekeningDelen.DatabaseManager.databaseInstance,
RekeningDelen.DatabaseManager.saveBillEventSQL,
function(error) {
console.log(error);
console.log('transaction failed billeventspersons table creation ');
},
function(transactionId, result) {
console.log("transcation success billeventspersons, set firstappboot to false");
store.setItem("firstAppBoot", "false");
}
);
}
The saveBillEvent contains a transaction which at a given moment calls the saveBillEventSQL
.
DatabaseManager.prototype.saveBillEventSQL = function(billEventModel, callback) {
//here i need the billEventModel to create the SQL
db.executeSql(
transactionId,
getAllBillEventsSQL,
null,
function(transactiondId, results) {
//here i want to call the callback
console.log('billevent saved ' + results);
},
function(response) {
alert('fail1');
console.log("SELECT billEvent query failed " + response);
}
);
}
This function contains the final callback, which should call the passed callback, for a certain query and also needs the billEventModel
to create the query. Thus the billEventModel and the callback should be passed to this function, but that's not possible since the transaction triggers it at a specific moment.
So my question is how to deal with this A(with params)->B(has params, but cant pass through)->C(needs params) problem?
I hope you all can understand my question, if not add a comment.