Sha256: ff14c9e97c82da45a8534b45369c8fecd1571aeb5d6bad08fd595e7e2a076da5
Contents?: true
Size: 679 Bytes
Versions: 12
Compression:
Stored size: 679 Bytes
Contents
function find_tags(collection, regex, query, limit) { var counts = db.eval( function(collection, regex, query){ var counts = {}; db[collection].find(query, {"tags":1}).limit(500).forEach( function(p){ if ( p.tags ){ for ( var i=0; i<p.tags.length; i++ ){ var name = p.tags[i]; if(name.match(regex) != null) counts[name] = 1 + ( counts[name] || 0 ); } } } ); return counts; }, collection, regex, query ); var tags = []; for ( var tag in counts ){ tags.push( { name : tag , count : counts[tag] } ) } return tags; }
Version data entries
12 entries across 12 versions & 2 rubygems