storesafe/cordova-sqlite-storage

Query should return an array [...]

HibernantBear opened this issue · 2 comments

this is the origin code:

    var payload, rows;
    if (!handler) {
      return;
    }
    rows = response.rows || [];
    payload = {
      rows: {
        item: function(i) {
          return rows[i];
        },
        length: rows.length
      },
      rowsAffected: response.rowsAffected || 0,
      insertId: response.insertId || void 0
    };
    handler(this, payload);

as you may have noticed that in the value 'paylaod', the 'rows' could be the array value 'rows' before, not a strange object makes me have to get index first then get the array member by an anonymous function.
it should be like this:

    payload = {
      rows: rows,
      rowsAffected: response.rowsAffected || 0,
      insertId: response.insertId || void 0
    };

My apologies for the delay, thanks for the feedback. You are right that it would be more efficient to return an array, however we do not to break the number of applications using this plugin. It is desired to return an array object with [] access but with item() function access, which seems to be consistent with Android HTML5 Web SQL access (using window.openDatabase). For consideration in a future release, would probably be sometime in 2H 2018. I took the liberty to update the title to better reflect what is actually wanted.

well, thanks for your reply. But still I'm wondering is there any possible adding an efficient way to access the data?