I’ve attached $cordovaSQLite
to my ionic app. Here is a basic example of the code.
function retrieve() {
var q = $q.defer();
var query = 'SELECT user_credentials, user_id FROM Users;';
$ionicPlatform.ready(function (){
$cordovaSQLite.execute(db, query).then(function(res) {
if (res.rows.length > 0) {
console.log("found user");
console.log(res);
console.log(JSON.stringify(res));
q.resolve(res.rows[0]);
} else {
console.log("no rows found");
q.resolve(false);
}
}, function (err) {
q.reject(err);
});
});
return q.promise;
}
When I test my app on a browser, my logs show this
rows: SQLResultSetRowList
0: Object
user_credentials: "asdf"
user_id: 234
length: 1
rowsAffected: 0
However when I view the logs when running on my iOS app, I receive
{"rows":{"length":1},"rowsAffected":0,"insertId":1}
My question is why am I not receiving the value of rows
? Why does this work on the browser but not on iOS?