We're building an Ionic 2 (currently beta 11).
We're using built-in SqlStorage database. From Android our app is able to read and write date just fine, but with iOS we can only write the data. When we attempt to read the data we get the number of rows returned but none of the actual data.
getQueueItems(): Promise<any> {
return new Promise<any>((resolve, reject) => {
this.sql.query('SELECT * FROM queue').then(
(res) => {
console.log(res, 'result');
// resolve(sqlResult.res.rows);
}
);
}).catch(() => {
});
}
The resultset looks like this:
{
"tx": {
"db": {
"openargs": {
"name":"__ionicstorage",
"location":2,
"createFromLocation":0,
"backupFlag":2,
"existingDatabase":false,
"dblocation":"nosync"
},
"dbname":"__ionicstorage"
},
"txlock":true,
"readOnly":false,
"executes":[],
"finalized":true
},
"res": {
"rows": {
"length":3
},
"rowsAffected":0
}
}
Does anyone know how we can read from SqlStorage so that iOS gets the data?
After a lot of searching and reading tons of forum posts we finally found the answer. I'm posting here for future searchers, hopefully it will help you.
The trick is that in order for the query results to be usable by all platforms you have to iterate through the result set yourself adding the appropriate objects as you go.