Last active
December 13, 2015 17:38
Revisions
-
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ Works.aggregate [ $unwind: '$tagsL' , $group: _id: '$tagsL', c: {$sum: 1} ], (err, tags) -> return done err if err console.log tags # [ { _id: 'javascript', c:40 }, etc... ] -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,4 @@ Works.aggregate [ $group: _id: 'tags', c: {$sum: 1} ], (err, tags) -> return done err if err console.log tags # [ { _id: 'javascript', c:40 }, etc... ] -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ Works.aggregate [ $unwind: 'tags' , $group: _id: 'tags', c: {$sum: 1} ], (err, tags) -> return done err if err console.log tags # [ { _id: 'javascript', c:1 }, etc... ] -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,12 @@ map = function() { return this.tagsL.forEach(function(tagL, i) { return emit(tagL, 1); }); }; reduce = function(k, vals) { print (k) print (vals) return vals.length; }; db.works.mapreduce(map, reduce) -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ o = {} o.map = -> if @tagsL @tagsL.forEach (tagL, i) -> emit tagL, 1 else return o.reduce = (k, vals) -> vals.length o.out = inline: 1 o.verbose = true mongoose.models.Work.mapReduce o, (err, tagsArray, stats) -> return done err if err console.log "Tag Count took %d ms", stats.processtime tags = {} async.forEach tagsArray, (tag, cb) -> tags[tag._id] = tag.value cb() , (err) -> tags #a key value list of tag: count -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ o.map = -> else return o.reduce = (k, vals) -> Array.sum vals o.out = inline: 1 o.verbose = true mongoose.models.Work.mapReduce o, (err, tagsArray, stats) -> -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ map = function() { return this.tagsL.forEach(function(tagL, i) { return emit(tagL, 1); }); } reduce = function(k, vals) { print (k) print (vals) return vals.length; }; -
kyriesent revised this gist
Feb 14, 2013 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ o = {} o.map = -> if @tagsL @tagsL.forEach (tagL, i) -> emit tagL, 1 else return o.reduce = (k, vals) -> vals.length o.out = inline: 1 -
kyriesent created this gist
Feb 13, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ o = {} o.map = -> @tagsL.forEach (tagL, i) -> emit tagL, 1 o.reduce = (k, vals) -> vals.length o.out = inline: 1 o.verbose = true mongoose.models.Work.mapReduce o, (err, tagsArray, stats) -> return done err if err console.log "Tag Count took %d ms", stats.processtime tags = {} async.forEach tagsArray, (tag, cb) -> tags[tag._id] = tag.value cb() , (err) -> tags #a key value list of tag: count