collection.mapReduce

Mongo documentation

Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.

Arguments

  1. map (function | string) - The mapping function.

  2. reduce (function | string) - The reduce function.

  3. options (Object) - Need to specify at least the out option.

  4. [callback] (function)

Returns

A promise.

Example

// Map function
var map = function () { emit(this.user_id, 1) }
// Reduce function
var reduce = function (k, vals) { return 1 }
users.mapReduce(map, reduce, {out: {replace: 'tempCollection'}}).then((collection) => {})

results matching ""

    No results matching ""