Skip to content

Instantly share code, notes, and snippets.

@alanhoff
Created November 4, 2012 17:27
Show Gist options
  • Select an option

  • Save alanhoff/4012686 to your computer and use it in GitHub Desktop.

Select an option

Save alanhoff/4012686 to your computer and use it in GitHub Desktop.
Folio.find().distinct('category', function(err, categories) {
var dadosCategoria = { };
var cat = [];
var loop = categories.length
categories.forEach(function(category){
Folio.count({'category' : category}, function(err, c) {
dadosCategoria.name = category;
dadosCategoria.count = c;
cat.push(dadosCategoria);
if(loop-- == 0)
render(cat)
});
});
console.log(cat);
});
function render(categories){
res.render('portifolio',
{
categories:cat,
title: 'Portifolio - Lucas Simon :: Portifolio'
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment