Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query should return an array [...] #755

Open
HibernantBear opened this issue Feb 17, 2018 · 2 comments
Open

Query should return an array [...] #755

HibernantBear opened this issue Feb 17, 2018 · 2 comments

Comments

@HibernantBear
Copy link

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
    };
HibernantBear added a commit to HibernantBear/Cordova-sqlite-storage that referenced this issue Feb 17, 2018
payloads can normally return an array not an strange object

BREAKING CHANGE: Break test and api relate to this change
Closes storesafe#755
@brody4hire brody4hire changed the title Query should return an array not an object Query should return an array [...] Mar 5, 2018
@brody4hire
Copy link

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.

@HibernantBear
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants