Source

fantomongo / fan / Collection.fan

Diff from to

File fan/Collection.fan

   
   **
   ** Perform a map reduce operation - 'map' and 'reduce' are JavaScript functions.
-  ** 'outputCollection' (optional) specifies the collection to store the results in, 
-  ** otherwise uses a temp collection.  'query' specifies a query to narrow the range 
-  ** of objects this is applied to - null will use all objects.  
+  ** 'out' (optional) specifies the collection to store the results in. 'query'
+  ** (optional) specifies a query to narrow the range of objects this is applied
+  ** to - null will use all objects.  
   **
   ** Returns a Map in which the key "result" is the Collection name created for the reults.
   ** Other info - processing time, etc is also included
   **
   ** See http://www.mongodb.org/display/DOCS/MapReduce
   **
-  Str:Obj? mapReduce(Str map, Str reduce, Str:Obj opts := [:])
+  Str:Obj? mapReduce(Str map, Str reduce, Str out := "reduceOut", Str:Obj opts := [:])
   {
     mrcmd := [:] { ordered = true }
-    mrcmd.set("mapreduce", name).set("map", map).set("reduce", reduce)
+    mrcmd.set("mapreduce", name).set("map", map).set("reduce", reduce).set("out", out)
     mrcmd.addAll(opts) // should probably make sure this is merged so above is not overwritten...
     res := db.command(mrcmd)
     if(!DB.cmdOk(res)) throw MongoOpErr("mapReduce failed - ${res}")