假设您的视图中包含以下数据以及这些键:
startkey == [a, 11]
and endkey == [c, 11]
:
[a, 10]
[a, 11] <-- startkey
[a, 12] <--
[b, 10] <--
[b, 11] <--
[b, 12] <--
[c, 10] <--
[c, 11] <-- endkey
[c, 12]
(所有用箭头标记的都将被返回)。
视图中的数据使用键排序。和startkey
and endkey
你可以控制去哪里start and end视图中。您无法指定限制条件对于数据。介于两者之间的所有内容startkey
and endkey
将被退回。请阅读http://wiki.apache.org/couchdb/View_collation http://wiki.apache.org/couchdb/View_collation了解更多信息。
如果你想进行地理空间查询,你应该查看 GeoCouch (https://github.com/couchbase/geocouch/ https://github.com/couchbase/geocouch/).
总结:CouchDB 视图中的键存储在一维列表中。这些列表中的条目根据以下规则排序查看排序规则 http://docs.couchdb.org/en/2.0.0/couchapp/views/collation.html。二维数组可能看起来很特殊,但实际上并非如此。[a, 10]
已排序after [a]
and after a
and before [b, 5]
and before [c]
(例如)。
如果你使用startkey
and endkey
,你说“一切,包括和之后startkey
以及之前和包括endkey
". startkey
and endkey
条目做not必须出现在列表中。