Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cascading selects #80

Open
diegodcl opened this issue May 9, 2018 · 1 comment
Open

cascading selects #80

diegodcl opened this issue May 9, 2018 · 1 comment

Comments

@diegodcl
Copy link

diegodcl commented May 9, 2018

I´m developing a app with cordova+framework7+sqlite-ext. The app works offline, and synchronize the collected data troughout the day, with a API on the server.

A JSON is builded selecting data from the database with a sql transaction and a lot of callbacks. Something like this:

db.transaction(function(tx){
tx.executeSql("select * from table1",[], function(tx, rs){
if (rs.rows.length>0) {
var tb1_id = rs.rows.item(0).tb1_id;
tx.executeSql("select * from table2 where father_id = ?,[tb1_id], function(tx,rs) {
tx.executeSql("select * from table3 where father_id = ?,[tb1_id], function(tx,rs) {
}
});
});

in between the "tx.executeSql" statments it´s loaded the results into an array of objects to be sent later to the API.

The problem is that I´m having trouble with the sync of these selects. The question is, the best way to do this kind of thing is via transaction? should I use readTransaction? should it be only the "executeSql" statments cascading? I noticed that the transaction API is deprecated.

@brodycj
Copy link
Owner

brodycj commented Dec 3, 2019

It would be ideal to do this in a readTransaction, then all data comes from the same state.

I had wanted to deprecate the transaction API but found that it is still needed by many users.

I am hoping to make a clean API redesign someday, see storesafe/cordova-sqlite-storage#862.

My apologies for the extremely long delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants