Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

couchdb: map in design document gives compilation_error

Tags:

couchdb

I use Couchdb 1.1.1 in Debian testing

and I have this design document in database

{
 "_id": "_design/Page",
 "_rev": "9-1944cdebabf20ae569eab7b534b43e67",
 "views": {
     "all": {
         "map": "function(doc) {}"
     }
 },
 "language": "javascript"
}

but still I get in http://localhost:5984/db_development/_design/Page/_view/all

this {"error":"compilation_error","reason":"Expression does not eval to a function. ((new String(\"function(doc) {}\")))"}

I tried to run different simple map functions in spidermonkey-bin interpreter and they was loaded correctly, but same error in couchdb

I really can't see, where problem is....

Ok, in mailing list I found that it is needed to wrap function to parentheses "()", because something has changed in newer spidermonkey

So map function looks like this: "map": "(function(doc) { emit([doc._id, doc._rev]);})"

like image 222
Ivan Stana Avatar asked Jan 27 '12 13:01

Ivan Stana


1 Answers

Ok, in mailing list I found that it is needed to wrap function to parentheses "()", because something has changed in newer spidermonkey

So map function looks like this: "map": "(function(doc) { emit([doc._id, doc._rev]);})"

like image 73
Ivan Stana Avatar answered Nov 15 '22 11:11

Ivan Stana