简体   繁体   中英

CouchDB replication using a selector

Trying to create CouchDB replication using a selector [1]: https://i.stack.imgur.com/d3XzH.png but the request returns an error "unknown builtin filter name".

Request URL is 'https://example.com/schemes/_changes?timeout=25000&style=all_docs&filter=_selector%2F_selector&since=0&limit=4'

Why is the selector duplicated (_selector%2F_selector) in the request?

public startReplication = async (): Promise<void> => {
this.database.sync(null, {
  pull: {
    live: true,
    retry: true,
    filter: undefined,
    selector: {
      selector: {
        author: '456w346456',
      },
      sort: ['modified', 'asc'],
      fields: ['firstField', 'secondField']
    },
    batch_size: 4
  },
  push: {
    live: true,
    retry: true,
  },
});

};

You probably want something like:

public startReplication = async (): Promise<void> => {
this.database.sync(null, {
  pull: {
    live: true,
    retry: true,
    filter: undefined,
    selector: {
      author: '456w346456',
    },
    batch_size: 4
  },
  push: {
    live: true,
    retry: true,
  },
});

The selector should just be an object describing the query that is to be applied to each change in the changes feed. In your example, you have a nested selector object within the selector.

Also your sort and fields keys are irrelevant here: it's not like the querying mechanism - you can't specify the sort order or which fields are to be returned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM