Search code examples
viewcouchbasecouchbase-sync-gateway

DateToArray is not defined in couchbase sync gateway


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?


Solution

  • 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.