Cordova-sqlite-storage: Select result only returns length of the matched results and not the items array

Created on 3 Jun 2019  路  3Comments  路  Source: storesafe/cordova-sqlite-storage

Hi. I'm using the plugin in Ionic v4 application.

const sqlQuery = 'SELECT user, consignment FROM users WHERE consignment = ?;';
const result = await this.db.transaction(tx => {
     tx.executeSql(sqlQuery, ['some_value'], (trx, res) => this.logger.debug('[sqlite-tx-update]', res, trx));
});

The result output that I get is

{
   "rows": {
         "length" : 1
    },
   "rowsAffected": 0
}

Here's my transaction config

{
     "db": {
     "openargs": {
            "name": "activity",
            "location": "default",
            "androidDatabaseProvider": "system",
            "androidLockWorkaround": 1,
            "dbLocation": "nosync",
            "androidOldDatabaseImplementation": 1,
            "androidBugWorkaround": 1,
        },
      "dbname": "activity"
      },
     "txlock": true,
     "readOnly": false,
     "executes": [],
     "finalized": true
}

I'm using the plugin version 3.2 on Android 9.0 device

invalid question doc-todo user community help doc-pitfall doc-clarity ionic

All 3 comments

Your use of the transaction API does not look right, specifically there is something wrong with the way you are using the res object. How to get the rows data from the res object is already documented, please double-check.

I'm sorry my bad, was considering item to be an array instead of a function. Please make an explicit note of that in the documentation.
I have used the transaction API as documented but using async await and it works fine.

was considering item to be an array instead of a function

No worries, I just marked this with doc-todo label. Yes this is a pitfall and documentation really needs cleanup now.

I have used the transaction API as documented but using async await and it works fine.

Interesting, I have never tried it myself.

P.S. While the demo code is for the Ionic wrapper API, which is not directly supported by this project, it demonstrates how callback API calls can be embedded in async (asynchronous) JavaScript functions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brodybits picture brodybits  路  5Comments

TommyQu picture TommyQu  路  3Comments

jreynerio picture jreynerio  路  5Comments

maoamid picture maoamid  路  4Comments

MASP3000 picture MASP3000  路  4Comments