1

I write the code for couchbase view. follow this 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
  });
}`

and when I call http://localhost:4984/{db}/_design/{ddoc}/_view/{view} I got an error

    Error running map function: ReferenceError: dateToArray is not defined

error image

I use sync-gateway version 1.4 What should I do?

Donut.s
  • 15
  • 4

2 Answers2

1

In order to be able to query views via the Sync Gateway, you should be creating it through the Sync Gateway REST interface. You cannot query for views directly created on Couchbase Server.

This link should provide more insights into creating and querying views via Sync Gateway

rajagp
  • 1,443
  • 8
  • 10
0

The blog post you're referring to is about Couchbase Server, not Sync Gateway. So, it looks like dateToArray is not a pre-defined function available on Sync Gateway.

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121