Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@jkuester

Description

@jkuester

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions