MongoCollectionmapreduce()

Runs a Map Reduce command

Usage

BOOLEAN = MongoCollectionmapreduce( datasource, collection, map, reduce, outputcollection, type, query, finalize )
Argument Summary
datasource datasource name. Name previously created using MongoRegister
collection collection name
map map function in javascript code
reduce reduce function in javascript code
outputcollection name of the collection to put the results
type the type of output; MERGE (Merge the job output with the existing contents of outputTarget collection), REDUCE (Save the job output to a collection, replacing its previous content), REPLACE (Reduce the job output with the existing contents of outputTarget collection) (default REPLACE) [optional]
query query to use on input [optional]
finalize finalize function in javascript code [optional]

Calling

Supports named-parameter calling allowing you to use the function like:

MongoCollectionmapreduce(
   datasource=?, 
   collection=?, 
   map=?, 
   reduce=?, 
   outputcollection=?, 
   type=?, 
   query=?, 
   finalize=?
);

Supports passing parameters as a structure using ArgumentCollection:

MongoCollectionmapreduce( ArgumentCollection={
   datasource : ?, 
   collection : ?, 
   map : ?, 
   reduce : ?, 
   outputcollection : ?, 
   type : ?, 
   query : ?, 
   finalize : ?
} );

Extra

For more information on using MongoDB, visit the MongoCFML page

For functions that update data, you can pass in the writeconcern. The possible values are:

  • FSYNC_SAFE
    Exceptions are raised for network issues, and server errors; the write operation waits for the server to flush the data to disk
  • JOURNAL_SAFE
    Exceptions are raised for network issues, and server errors; the write operation waits for the server to group commit to the journal file on disk
  • MAJORITY
    Exceptions are raised for network issues, and server errors; waits on a majority of servers for the write operation
  • NONE
    No exceptions are raised, even for network issues
  • NORMAL
    Exceptions are raised for network issues, but not server errors
  • REPLICAS_SAFE
    Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation
  • SAFE
    Exceptions are raised for network issues, and server errors; waits on a server for the write operation