3
votes
db.myCollection.mapReduce(function()
  {emit (this.id, this.amount);},
  {
  query:{status:"normal"},
  out:"myCollections"
  }
  )

I tried to use map reduce function in Robomongo UI. I got the following error.

assert failed : need to supply an optionsOrOutString Error("Printing Stack Trace")@:0 ()@src/mongo/shell/utils.js:37 ("assert failed : need to supply an optionsOrOutString")@src/mongo/shell/assert.js:6

Can anyone please help me find out why the error is occuring?

1

1 Answers

4
votes

You do not have a reducer. Even if you expect no reduce stage to fire in such a query it is still required. So just use a blank function

db.myCollection.mapReduce(
  function(){
      emit (this.id, this.amount);
  },
  function(){},
  {
      "query":{ status:"normal" },
      "out":"myCollections"
  }
)