Here's a question for you - in the context of Ionic 3, what would be the preferable approach: keeping the opened database as a private member variable within a database provider class, or calling create
every time a query is made to the database?
For example...
private db: SQLiteObject;
constructor() {
this.sqlite.create(...)
.then((db: SQLiteObject) => {
this.db = db;
})
}
queryMethod() {
db.executeSql(sql, {});
}
...or perhaps like this?
constructor() {
}
queryMethod() {
this.sqlite.create(...)
.then((db: SQLiteObject) => {
db.executeSql(sql, {});
});
}
I do recognize a potential issue with the first approach, as there is a chance that the database might not have been created prior to being accessed.