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

Inconsistant/undocumented difference between default limit on find calls when using http vs local adapter #8927

Closed
jkuester opened this issue Apr 11, 2024 · 1 comment · Fixed by #8936

Comments

@jkuester
Copy link
Contributor

jkuester commented Apr 11, 2024

Issue

When calling the find function, the request.limit value is optional. However, if you do not provide a limit value, the amount of data returned will differ based on if you are using the http adapter (connecting to a CouchDB instance) vs a local adapter.

The CouchDB docs for _find say:

limit (number) – Maximum number of results returned. Default is 25. Optional

I cannot find any mention of a default limit size in the Pouch docs:

My question is: should the limit on Pouch find behave the same way as Couch _find, where, by default, the limit is 25 on both the local and the http adapter? If not, can we at least update the docs to call out that the default limit value may differ based on which adapter you are using?

Reproduce

You can demonstrate what I am talking about by adding a new test to test.limit.js

  it('should consistently limit the results', function () {
    const  extraDocs = Array.from({ length: 3000 }, (_, i) => ({ name: `Test${i}`, rank: 5, series: 'Test', debut: 1981 }));

    var db = context.db;
    return db.bulkDocs(extraDocs).then(function () {
      return db.find({
        selector: {
          series: 'Test'
        },
        fields: ['_id']
      });
    }).then(function (res) {
      res.docs.length.should.equal(3000);
    });
  });

This test will succeed when running with the local adapter since all 3000 results will be returned. It will fail if you instead connect Pouch to a Couch instance via the http adapter. Only 25 results will be returned in that case.

@garethbowen
Copy link
Member

Pouch generally aims for API compatibility with Couch so let's go ahead and update the implementation and docs to have a default of 25. This is technically a breaking change so should be included in the next major (coming soon)!

Having different adapters with different defaults is particularly confusing!

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

Successfully merging a pull request may close this issue.

2 participants