What is best practice for waiting to ensure all tables are created before continuing?
I am currently just nesting each create table in the then of the previous, like so.
$cordovaSQLite.execute(self.db, "CREATE TABLE IF NOT EXISTS table1(id integer primary key, field1 text, field2 tex)")
.then(function(res) {
$cordovaSQLite.execute(self.db, "CREATE TABLE IF NOT EXISTS table2(id integer primary key, field1 text, field2 tex)")
.then(function(res) {
$cordovaSQLite.execute(self.db, "CREATE TABLE IF NOT EXISTS table3(id integer primary key, field1 text, field2 tex)")
.then(function(res) {
// return something here
});
});
});
I am asking because I built a phonegap app previously that used SQLite and there were problems with the creation of tables and inserting data into them, the creation sometime took long enough that it tried to insert before the table was ready.
so my question is this: is it possible to create the tables and not have to nest these functions but still ensure they are all finished before continuing? i haven’t seen any examples of this yet.