Google News
logo
MongoDB - Interview Questions
Explain the purpose of map-reduce command in Mongo-DB.
Map-reduce is a method of performing aggregation.
 
* Map function emits key-value pair specified.
* Reduce function combines the key value pair and returns the aggregation result.

Syntax :
db.collection.mapReduce( 
 function() {emit(key,value);}, 
 function(key, values) {return aggregatedResult}, { out: collection } 
</pre.
 )

 

Advertisement