node.js SDK中Couchbase的Startkey和endKey

Couchbase's Startkey and endKey in the node.js SDK

Docs on view querying

startKeyendKey 可用于查找键的范围。在 scouring the documentation 之后,我在 node.js SDK 2.0

中找不到任何提及它们的地方

如何在创建 ViewQuery 请求时指定 startKeyendKey?它们是否作为 Bucket#query 中神秘的 "options" 参数传递?

换句话说,如果我只想要该视图的某个子集,我不太清楚如何 运行 对该视图进行查询。如果一个视图索引了一百万个文档,而我不知道它的名字,有没有办法按类型找到它,或者我是否必须有一个完全独立的视图,只按类型索引?

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