CouchDB视图:total_rows,offset和rows? [英] CouchDB views: total_rows vs offset vs rows?

查看:97
本文介绍了CouchDB视图:total_rows,offset和rows?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向CouchDB发出POST请求,并在正文中列出了密钥。

I am making a POST request to a CouchDB with a list of keys in the body.

这是在此处有关堆栈溢出的上一个问题的跟进:具有多个键格式的CouchDB查询视图)。

This is a follow up on a previous question asked on Stack Overflow here: CouchDB Query View with Multiple Keys Formatting).

我看到结果返回了711行在这种情况下,偏移量为209。对我而言,偏移量表示已被截断的有效结果-您需要转到下一页才能看到它们。

I see that the result has 711 rows returned in this case, with an offset of 209. To me an offset means valid results that have been truncated - and you would need to go to the next page to see them.

我很困惑,因为偏移量,行数以及我实际得到的似乎没有加起来。这些是我得到的结果:

I'm getting confused because the offset, rows, and what I actually get does not seem to add up. These are the results that I'm getting:

{
  total_rows: 711,
  offset: 209,
  rows: [{
    id: 'b45d1be2-9173-4008-9240-41b01b66b5de',
    key: 2213,
    value: [Object]
  }, {
    id: 'a73d0b13-5d36-431f-8a7a-2f2b45cb480d',
    key: 2214,
    value: [Object]
  }, 
    etc BUT THERE ARE ONLY 303 OBJECTS IN THIS ARRAY????
  ]
}


推荐答案

您没有提供您正在使用的查询参数,因此我必须要有点笼统。

You have not supplied the query parameters you are using so I'll have to be a little general.

total_rows value是视图本身中的总行数。 offset 是给定查询的第一个匹配行视图中的索引。在数组中返回与查询参数匹配的行数,这些行的总数很小。

The total_rows value is the total number of rows in the view itself. The offset is the index in the view of the first matching row for the given query. The number of rows matching the query parameters are returned in the rows array, the total of which are trivial to obtain.

如果视图中没有用于直接键查询的条目,则偏移值是视图中具有所需键的条目所在的索引。

If there are no entries in the view for a direct key query, the offset value is the index into the view where the entry would be if it had the desired key.

这篇关于CouchDB视图:total_rows,offset和rows?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆