2

I am trying to get a simple map reduce working in MongoVUE, but it doesn't return any results, I just want to get it to output the count of each userID just so I can have a working example to build from.

function Map() {
emit( this.UpdatedBy.UserId, {"count": 1} );
}

function Reduce(key, values) {

var result = {count: 0};
  values.forEach(function(value) {
  result.count += value.count;
});
return result;
}

function Finalize(key, reduced) {
/*  
reduced = Transform-to-Desired-Form(reduced);
*/
return reduced;
}

And the output is set to inline.

This is the tutorial I am working from, but I just want to apply a simple count to start off with http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/

Dorf
  • 229
  • 6
  • 15

2 Answers2

3
function() {
    emit( this.UpdatedBy.UserId, 1 );
  };


  function(key, values) {
    var result =  0;

    values.forEach(function(value) {
      result += value;
    });
    return result;
  };

Here is how I got it to work for anyone who needs a simple example on how to group and count a user Id.

Dorf
  • 229
  • 6
  • 15
0

I just wrote a blog post and made two short screencasts showing exactly how to get an example MapReduce working in MongoVue

Lynn Langit
  • 4,030
  • 1
  • 23
  • 31