This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//count dups in mongo with mapReduce | |
m = function() { emit(this.user_id, 1); }; | |
r = function (k, vals) { return Array.sum(vals); }; | |
res = db.tasks.mapReduce(m, r, { out : {replace : "results", db : "mr"}}); | |
// more difficult | |
function map() { | |
var sorted = this._keywords.sort(); | |
key = sorted.join(" "); | |
var ret = {title : this.title, id : this._id, total: 1}; |
NewerOlder