INNER CODE UNIT · JavaScript

tagCloud

mongodb/mongo-snippets · js/blog.js:36

function tagCloud(){
    
    print( db.version() )

    var res = db.posts.mapReduce( 
        function(){ 
            for ( var i=0; i<this.tags.length; i++ ){
                var name = this.tags[i];
                emit( this.tags[i] , 1 );
            }
        } ,
        function( key , values ){
            return Array.sum( values );
        }
        , { out : { inline : true } } )

    assert( res.ok );
    

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…