使用选择器进行 CouchDB 复制

发布于 2025-01-10 14:15:42 字数 745 浏览 0 评论 0原文

尝试使用选择器创建 CouchDB 复制 [1]: https://i.sstatic.net/d3XzH.png 但请求返回错误“未知的内置过滤器名称”。

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

为什么选择器在要求?

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,
  },
});

};

Trying to create CouchDB replication using a selector
[1]: https://i.sstatic.net/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,
  },
});

};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑忘罢 2025-01-17 14:15:42

您可能想要类似的东西:

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,
  },
});

选择器应该只是一个描述要应用于更改提要中的每个更改的查询的对象。在您的示例中,选择器内有一个嵌套的 selector 对象。

此外,您的 sortfields 键在这里无关紧要:它不像查询机制 - 您无法指定排序顺序或要返回哪些字段。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文