couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Why can't I use "var" in map code?
Date Fri, 17 Jul 2009 09:18:11 GMT
Could somebody explain this subtlety of Javascript to me?

This works fine:

$ curl -X POST -d '{"map":"x=123; function(doc) { emit(x,null); }"}'

But this doesn't:

$ curl -X POST -d '{"map":"var x=123; function(doc) { emit(x,null); }"}'
{"error":"compilation_error","reason":"expression does not eval to a function. (var x=123;
function(doc) { emit(x,null); })"}

The only difference is the addition of the word 'var'.

(The reason: I'm writing a map function which needs to use a precalculated
lookup table)



View raw message