Build 1554 vars in reduce function
Mon, 08/27/2012 - 01:29
I've used Couchbase DP4. There I have such reduce functions:
var tmp = [];
var t = [];
function findRecent(arr){
var max = 0;
var maxId = 0;
for (var i in arr){
if (arr[i].Date > max){
max = arr[i].Date;
maxId = i;
}
}
return arr[maxId];
}
function(k,v,r){
if (!r){
tmp.push(v);
}
else{
tmp.push(v);
}
if (r){
for (var i1 in tmp[0])
{
t.push(tmp[0][i1]);
}
} else {
return findRecent(v);
}
return findRecent(t);
}They worked fine in DP4. But in build 1554 when I try to save such reduce function server says:
Syntax error in the reduce function of the view `MyView': SyntaxError: Unexpected token var
Also I can't define any other function: only 1 function (function(k,v,r){...}) is valid.