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

Fields param is missing for changesreader.get #263

Open
kozlovzxc opened this issue Apr 14, 2021 · 0 comments
Open

Fields param is missing for changesreader.get #263

kozlovzxc opened this issue Apr 14, 2021 · 0 comments

Comments

@kozlovzxc
Copy link

Expected Behavior

The CouchDB documentation describes that it is possible to provide _selector for _chages handler

POST /recipes/_changes?filter=_selector HTTP/1.1
Content-Type: application/json
Host: localhost:5984

{
    "selector": { "_id": { "$regex": "^_design/" } }
}

The documentation also describes that selector can contain a list of specified fields to filter.

{
    "selector": { "Actor_name": "Robert De Niro" },
    "fields": ["Actor_name", "Movie_year", "_id", "_rev"]
}

Current Behavior

Right now it is only possible to provide the selector parameter, but not the fields parameter. Link

          if (self.selector) {
            req.qs.filter = '_selector'
            req.body.selector = self.selector
          }

Possible Solution

Locally I've fixed it just by adding another parameter. It can be something like this:

          if (self.selector || self.fields) {
            req.qs.filter = '_selector'
            req.body.selector = self.selector
            req.body.fields = self.fields
          }

It also may worth adding another custom body param similar to qs, which adds additional body params.

          Object.assign(req.qs, opts.qs)
          // New
          Object.assign(req.body, opts.body)

Steps to Reproduce (for bugs)

It should be straightforward to reproduce, but I can add exact steps if needed.

Context

I was trying to fetch few fields from https://replicate.npmjs.com, but I didn't need all extra fields as versions, because it noticeably slows the script down and increases network consumption.

More context

Your Environment

  • Version used: "nano": "^9.0.3",
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

No branches or pull requests

1 participant