Sha256: 2eb5ced5c1e26272cdb7e27a76f1f18a55579a0a3a88e298607cee53ad56e34b
Contents?: true
Size: 589 Bytes
Versions: 3
Compression:
Stored size: 589 Bytes
Contents
function findTags(collection, regex, query, limit) { var tags = db.eval( function(collection, regex, query){ var tags = []; 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 && tags.indexOf(name) == -1) tags.push(name); } } } ); return tags; }, collection, regex, query ); return tags.slice(0,limit||30); }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongomapper_ext-0.1.5 | lib/mongomapper_ext/js/find_tags.js |
mongomapper_ext-0.1.4 | lib/mongomapper_ext/js/find_tags.js |
mongomapper_ext-0.1.3 | lib/mongomapper_ext/js/find_tags.js |