startKey
和 endKey
对于查找键范围非常有用。之后scouring the documentation ,我在node.js SDK 2.0中找不到任何提及它们的内容
创建 ViewQuery
请求时如何指定 startKey
和 endKey
?它们是否作为 Bucket#query
中神秘的“选项”参数传递?
换句话说,如果我只想要该 View 的某个子集,我不太清楚如何在 View 上运行查询。如果一个 View 索引了一百万个文档,而我不知道它的名称,有没有办法按类型查找它,或者我是否必须有一个完全独立的 View ,仅按类型索引?
最佳答案
ViewQuery
对象有一个名为 range
的方法,可让您指定开始键和结束键。由于某种原因它没有出现在当前文档中,但是您可以在客户端源代码中看到该方法定义:
ViewQuery.prototype.range = function(start, end, inclusive_end) {
this.options.startkey = JSON.stringify(start);
this.options.endkey = JSON.stringify(end);
if (inclusive_end) {
this.options.inclusive_end = 'true';
} else {
delete this.options.inclusive_end;
}
return this;
};
关于javascript - Node.js SDK中Couchbase的Startkey和endKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29453724/