2

I did not find any documentation on the Date object that is used within a map function of a couchDB view. There is some strange behaviour that I encountered and I need some closure.

Following code:

emit(doc.type, { date: new Date() })

outputs:

{ date: "2012-03-10T18:57:32.408Z" }

Yet using:

emit(doc.type, { date: new Date("1984-12-10") })

outputs:

{ date: "Invalid Date" }

So what Date object is couchDB using here? It cannot be the JavaScript one, because new Date("1984-12-10") works there. couchDB however expects the date in a "1984/12/10" format.

Does anybody has any information concerning this issue?

Amberlamps
  • 39,180
  • 5
  • 43
  • 53

1 Answers1

1

CouchDB's views are parsed with SpiderMonkey. I believe CouchDB 1.1.1 added support for a much newer version of SpiderMonkey(1.8.5). It's quite possible you are still running an older version of SpiderMonkey that doesn't properly handle Date() as you would expect. I don't know anything about your platform so I cannot recommend an upgrade path but I believe this is what you're experiencing.

rwilliams
  • 21,188
  • 6
  • 49
  • 55