如何使用“自从” Cloudant DB 更改源中的参数?

发布于 2025-01-11 13:12:27 字数 188 浏览 2 评论 0原文

我正在使用 Cloudant 数据库,并且希望通过 _changes API 调用在更改源中使用 since 参数。正在寻找有关 since 参数的有效条目的指导。我知道 0now 是选项,但有没有办法从定义的时间段获取更改?

I am working with a Cloudant db and would like to use the since param in the changes feed using the _changes API call. Was looking for guidance one what would be valid entries for the since parameter. I know 0 and now are options but is there a way to get changes from a defined time period?

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

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

发布评论

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

评论(1

心的位置 2025-01-18 13:12:27

每当您调用 _changes API 端点时,您都​​会在响应中获得 last_seq 参数。这是一个令牌,可以在后续 API 调用中提供给 _changes 端点以获取下一批更改。

例如,如果您进行初始调用以获取名为 orders 的数据库中的更改:

GET /orders/_changes?limit=5
{
  "results": [
    {
      "seq": "1-g1AAAAB5eJzLYWBg",
      "id": "00002Sc12XI8HD0YIBJ92n9ozC0Z7TaO",
      "changes": [
        {
          "rev": "1-3ef45fdbb0a5245634dc31be69db35f7"
        }
      ]
    },
    ....
  ],
  "last_seq": "5-g1AAAAB5eJzLYWBg"
}

...然后您可以使用返回的 last_seq 参数获取后续更改:

GET /orders/_changes?limit=5&since=5-g1AAAAB5eJzLYWBg
{
  "results": [ ...],
  "last_seq": "10-g1AAAACbeJzLY"
}

但是,应该指出的是,由于多种原因,针对此更改源的编程很复杂。例如,改变没有严格按时间顺序排序,并且可能在调用之间重复。请阅读此常见问题解答文档了解更多详细信息。

Whenever you call the _changes API endpoint, you get a last_seq parameter in the response. This is a token that can be supplied to the _changes endpoint in a subsequent API call to get the next batch of changes.

For example, if you make an initial call to get changes in a database called orders:

GET /orders/_changes?limit=5
{
  "results": [
    {
      "seq": "1-g1AAAAB5eJzLYWBg",
      "id": "00002Sc12XI8HD0YIBJ92n9ozC0Z7TaO",
      "changes": [
        {
          "rev": "1-3ef45fdbb0a5245634dc31be69db35f7"
        }
      ]
    },
    ....
  ],
  "last_seq": "5-g1AAAAB5eJzLYWBg"
}

...you can then get subsequent changes by using the returned last_seq parameter:

GET /orders/_changes?limit=5&since=5-g1AAAAB5eJzLYWBg
{
  "results": [ ...],
  "last_seq": "10-g1AAAACbeJzLY"
}

However, it should be noted that programming against this changes feed is complicated for a number of reasons. For example, the changes are not strictly ordered in time sequence and may be duplicated between calls. Please read this FAQ document for more details.

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