couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Leeds <>
Subject Re: Help for reduce function to get view working as needed...
Date Sat, 29 Jan 2011 20:32:36 GMT
There is no need for a reduce function here since there is no false value.
You want to do all this work in your map() function.

function(doc) {
  var heim = doc.heim;
  var gast = doc.gast;
  //I am not a JS wizard
  //Manipulate these values to remove the number
  emit(heim, null);
  emit(gast, null);

That should be all you need. No reduce.
I hope that helps!

Kind regards,

On Sat, Jan 29, 2011 at 09:14, Steffen Mutter <> wrote:
> Hello,
> I need some help to write a function to reduce a view.
> The view actually looks like this:
> function(doc) {
>  emit(doc.heim,null);
>  emit(doc.gast,null);
> }
> The reduce function looks actually like this:
> function(keys, values) {
>  return true;
> }
> The output is nearly the way I want it, but I want to reduce the output,
> so that if there is a single (!) number at the end of the key, I want to
> cut it off and trim the string if there are spaces left.
> The thing behind it is that the CouchDB stores all the matches of the
> german handball federation and some of the teams have a number behind
> the name of the club, so the view looks like this actually:
> "SG Stutensee" true
> "SG Stutensee 2"  true
> "SG Stutensee 3"  true
> "SG Stutensee 4"  true
> what I want is, that there's only
> "SG Stutensee" true
> left, so that I have only (once) the name of the club left.
> The next thing is, how to write a view to get all the games the *club*
> playes in, so that
> "SG Stutensee" would match to all 4 teams.
> Kind regards from Germany,
> Steffen

View raw message