DateToArray 未在 couchbase 同步网关中定义

DateToArray is not defined in couchbase sync gateway

我编写沙发底座视图的代码。按照这个 https://blog.couchbase.com/understanding-grouplevel-view-queries-compound-keys/

const mapDate = `function(doc, meta) {
  emit(dateToArray(doc.updatedAt), {
     _id: meta.id,
     _rev: meta.rev,
     updatedAt: doc.updatedAt
  });
}`

当我调用 http://localhost:4984/{db}/_design/{ddoc}/_view/{view} 时出现错误

    Error running map function: ReferenceError: dateToArray is not defined

error image

我使用同步网关版本 1.4 我该怎么办?

您所指的博客 post 是关于 Couchbase Server 的,而不是 Sync Gateway。所以,看起来 dateToArray 不是 Sync Gateway 上可用的 pre-defined 函数。

为了能够通过同步网关查询视图,您应该通过 Sync Gateway REST interface 创建它。您不能查询直接在 Couchbase 服务器上创建的视图。

link 应该提供有关通过 Sync Gateway 创建和查询视图的更多见解