Hi Raj
At a guess you're trying to get the doc count based on a particular
characteristic of the doc.
You might want to try something like
function (doc) {
emit(doc.i, doc);
}
function (keys, vals) {
return sum(vals);
}
and then query with something like
/my_db/_view/app/by_i?startkey=null&endkey=pivot
/my_db/_view/app/by_i?startkey=pivot&endkey={}
varying pivot as you wish.
If you wanted to see all the docs, simply query with reduce=false
Also your reduce function probably wouldn't behave as you'd expect
when invoked as a rereduce - at some point the values param would be
[values.length, a, b] array returned from a previous invocation.
Hope this helps
Paul
On Wed, Dec 17, 2008 at 3:43 PM, Rajkumar S <[email protected]> wrote:
> Hi,
>
> I have a (simplified) reduce function like
>
>
> function(key,values){
> var a,b;
> for (var i=0; i< values.length; ++i) {
> if (values[i] < 6){
> a++;
> } else {
> b++;
> }
> }
> }
> return [values.length,a,b];
> }
>
> The value 6 here is hard coded, is it possible to pass this via some
> sort of arguments? Also how can I retrieve all results of a view ?
>
> Thanks and regards,
>
> raj
>