Skip to content

Conversation

haoxins
Copy link
Member

@haoxins haoxins commented Jan 15, 2015

No description provided.

@jonathanong
Copy link
Contributor

what if i want to return the results immediately instead of through the collection?

@haoxins
Copy link
Member Author

haoxins commented Jan 16, 2015

the logic of mongodb-native is

    // If we wish for no verbosity
    if(options['verbose'] == null || !options['verbose']) {
      return handleCallback(callback, err, collection);
    }
    // Return stats as third set of values
    handleCallback(callback, err, collection, stats);

so, how about

.mapReduce().map(map).reduce(reduce).verbose(true).then(function (stats) {})
.mapReduce().map(map).reduce(reduce).then(function (collection) {})

// or
.mapReduce().map(map).reduce(reduce).then(function (result) {
  // contain both `stats` and `collection` in result
  // result: { stats: stats, collection: collection }
  // or
  // just contain `collection` in `stats`
  // result: { processtime: ..., counts: ..., timing: ..., collection: collection }
})

@jonathanong
Copy link
Contributor

ah. i didn't realize people actually looked at stats n stuff. i was thinking about inline: http://docs.mongodb.org/manual/reference/command/mapReduce/#output-inline

how do you use map/reduce? i've only ever used inline

@jonathanong
Copy link
Contributor

i'm thinking of .out(collection, [options]) for writing to a collection http://docs.mongodb.org/manual/reference/command/mapReduce/#output-to-a-collection-with-an-action, then .inline() for writing it directly out. or just make inline default.

@haoxins
Copy link
Member Author

haoxins commented Jan 16, 2015

😢 yes, inline for most cases.

updated.

@jonathanong
Copy link
Contributor

cool. looks good. the only thing i'd add is .out('collectionName'). is that supported?

@haoxins
Copy link
Member Author

haoxins commented Jan 17, 2015

yes, supported. maybe add a test is better.

@jonathanong
Copy link
Contributor

32335bd thanks :D

@jonathanong jonathanong deleted the map-reduce branch January 18, 2015 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants